From 03d3dc088606dee87c07a68b7db4b9ff8e2acfdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez=20Di=20Antonio?= Date: Sat, 19 Sep 2026 11:41:39 +0200 Subject: [PATCH] chore: move to Go 1.27.1 go directive 1.22.0 -> 1.27.1, matching every current consumer of this module (all on 1.26.3 or newer) and the toolchain the maintainers run. Consumers pin v0.0.4 and are unaffected until they upgrade; from then on they need Go 1.27. go fix applied its 1.27 rewrites in the example tests (range-over-int, atomic.Int32). The three unchecked w.Write calls in http_retrier_test.go that errcheck reported are now explicitly discarded. Co-Authored-By: Claude Fable 5.1 --- .github/copilot-instructions.md | 2 +- README.md | 2 +- example_http_client_test.go | 2 +- example_http_retrier_test.go | 14 +++++++------- go.mod | 2 +- http_retrier_test.go | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 11b689e..0eeedfd 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -5,7 +5,7 @@ Follows these guidelines precisely to ensure consistency and maintainability of ## Stack -- Language: Go (Go 1.22+) +- Language: Go (Go 1.27+) - Framework: Go standard library - Testing: Go's built-in testing package - Dependency Management: Go modules diff --git a/README.md b/README.md index 8eebb23..417d9d0 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ A comprehensive Go package for building and executing HTTP requests with advance ## Installation -**Requirements:** Go 1.22 or higher +**Requirements:** Go 1.27 or higher ```bash go get github.com/slashdevops/httpx diff --git a/example_http_client_test.go b/example_http_client_test.go index 14f4f5a..3a49a99 100644 --- a/example_http_client_test.go +++ b/example_http_client_test.go @@ -112,7 +112,7 @@ func ExampleNewClientBuilder_connectionPooling() { Build() // Reuse connections efficiently across multiple requests - for i := 0; i < 10; i++ { + for i := range 10 { resp, err := client.Get(fmt.Sprintf("https://api.example.com/items/%d", i)) if err != nil { log.Printf("Request %d failed: %v", i, err) diff --git a/example_http_retrier_test.go b/example_http_retrier_test.go index c304ea4..fb178ee 100644 --- a/example_http_retrier_test.go +++ b/example_http_retrier_test.go @@ -13,9 +13,9 @@ import ( // Example demonstrates using exponential backoff. func Example() { - var requestCount int32 + var requestCount atomic.Int32 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - count := atomic.AddInt32(&requestCount, 1) + count := requestCount.Add(1) if count <= 3 { // Fail first 3 times fmt.Printf("Server: Request %d -> 500 Internal Server Error\n", count) w.WriteHeader(http.StatusInternalServerError) @@ -60,11 +60,11 @@ func Example() { // ExampleNewHTTPRetryClient_withExistingAuth demonstrates how the default client // transparently preserves existing authentication headers in requests. func ExampleNewHTTPRetryClient_withExistingAuth() { - var requestCount int32 + var requestCount atomic.Int32 // Create a server that requires authentication server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - count := atomic.AddInt32(&requestCount, 1) + count := requestCount.Add(1) auth := r.Header.Get("Authorization") if auth == "" { @@ -107,7 +107,7 @@ func ExampleNewHTTPRetryClient_withExistingAuth() { body, _ := io.ReadAll(resp.Body) fmt.Printf("Client: Success! Status=%s, Body='%s'\n", resp.Status, string(body)) - fmt.Printf("Client: Auth header preserved through %d retries\n", atomic.LoadInt32(&requestCount)) + fmt.Printf("Client: Auth header preserved through %d retries\n", requestCount.Load()) // Output: // Client: Making authenticated request... @@ -167,11 +167,11 @@ func ExampleNewClientBuilder_transparent() { // ExampleNewHTTPRetryClient_withCustomTransport demonstrates using a custom base transport // with specific transport settings while maintaining transparent retry behavior. func ExampleNewHTTPRetryClient_withCustomTransport() { - var requestCount int32 + var requestCount atomic.Int32 // Create a test server that fails initially to show retry behavior with custom transport server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - count := atomic.AddInt32(&requestCount, 1) + count := requestCount.Add(1) fmt.Printf("Server: Request %d from custom transport\n", count) if count <= 1 { diff --git a/go.mod b/go.mod index bd44626..3bc40dc 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/slashdevops/httpx -go 1.22.0 +go 1.27.1 diff --git a/http_retrier_test.go b/http_retrier_test.go index 52ff2d4..dff17a9 100644 --- a/http_retrier_test.go +++ b/http_retrier_test.go @@ -906,7 +906,7 @@ func TestRetryTransport_ServerExceedsClientTimeout(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { time.Sleep(500 * time.Millisecond) // Server delays response w.WriteHeader(http.StatusOK) - w.Write([]byte("OK")) + _, _ = w.Write([]byte("OK")) })) defer server.Close() @@ -942,7 +942,7 @@ func TestRetryTransport_LargeTimeoutPreserved(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { time.Sleep(200 * time.Millisecond) // Simulate slow response w.WriteHeader(http.StatusOK) - w.Write([]byte("OK")) + _, _ = w.Write([]byte("OK")) })) defer server.Close() @@ -979,7 +979,7 @@ func TestRetryTransport_ContextTimeout(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { time.Sleep(500 * time.Millisecond) w.WriteHeader(http.StatusOK) - w.Write([]byte("OK")) + _, _ = w.Write([]byte("OK")) })) defer server.Close() @@ -1014,7 +1014,7 @@ func TestRetryTransport_ContextCancellation(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { time.Sleep(500 * time.Millisecond) w.WriteHeader(http.StatusOK) - w.Write([]byte("OK")) + _, _ = w.Write([]byte("OK")) })) defer server.Close()