From 756fcb8d630fc10c53e2cc0f824c3b53112a6cba Mon Sep 17 00:00:00 2001 From: James Raspass Date: Mon, 31 Aug 2026 09:58:08 +0100 Subject: [PATCH] Bump minimum Go to 1.24, use b.Loop() (#1164) Go 1.27 is out now so we can bump our minimum Go to 1.24 --- .github/workflows/ci.yml | 2 +- go.mod | 2 +- middleware/client_ip_bench_test.go | 4 ++-- middleware/throttle_test.go | 3 +-- mux_test.go | 4 +--- tree_test.go | 4 +--- 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a35409..625c661 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: - go-version: [1.23.x, 1.24.x, 1.25.x, 1.26.x] + go-version: [1.24.x, 1.25.x, 1.26.x, 1.27.x] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} diff --git a/go.mod b/go.mod index 51c2792..84133ac 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/go-chi/chi/v5 // Chi supports the four most recent major versions of Go. // See https://github.com/go-chi/chi/issues/963. -go 1.23 +go 1.24 diff --git a/middleware/client_ip_bench_test.go b/middleware/client_ip_bench_test.go index dbb7719..4ecc23c 100644 --- a/middleware/client_ip_bench_test.go +++ b/middleware/client_ip_bench_test.go @@ -25,7 +25,7 @@ func BenchmarkWalkXFF(b *testing.B) { b.Run(fmt.Sprintf("n=%d", n), func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { + for b.Loop() { walkXFF(headers, func(entry string) bool { return false // walk to the leftmost entry }) @@ -48,7 +48,7 @@ func BenchmarkWalkXFF_RightmostStop(b *testing.B) { b.Run(fmt.Sprintf("n=%d", n), func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { + for b.Loop() { walkXFF(headers, func(entry string) bool { return true // stop at the rightmost entry }) diff --git a/middleware/throttle_test.go b/middleware/throttle_test.go index 640258e..762c956 100644 --- a/middleware/throttle_test.go +++ b/middleware/throttle_test.go @@ -321,9 +321,8 @@ func BenchmarkThrottle(b *testing.B) { req := httptest.NewRequest("GET", "/", nil) - b.ResetTimer() b.ReportAllocs() - for i := 0; i < b.N; i++ { + for b.Loop() { w := httptest.NewRecorder() handler.ServeHTTP(w, req) } diff --git a/mux_test.go b/mux_test.go index 06cd868..9d0e7cc 100644 --- a/mux_test.go +++ b/mux_test.go @@ -2153,9 +2153,7 @@ func BenchmarkMux(b *testing.B) { r, _ := http.NewRequest("GET", path, nil) b.ReportAllocs() - b.ResetTimer() - - for i := 0; i < b.N; i++ { + for b.Loop() { mx.ServeHTTP(w, r) } }) diff --git a/tree_test.go b/tree_test.go index 881bfd9..6b542d8 100644 --- a/tree_test.go +++ b/tree_test.go @@ -503,9 +503,7 @@ func BenchmarkTreeGet(b *testing.B) { mctx := NewRouteContext() b.ReportAllocs() - b.ResetTimer() - - for i := 0; i < b.N; i++ { + for b.Loop() { mctx.Reset() tr.FindRoute(mctx, mGET, "/ping/123/456") }