Bump minimum Go to 1.23, always use request.Pattern (#1048)

Go 1.26 is out now so we can bump our minimum Go to 1.23
This commit is contained in:
James Raspass 2026-02-19 13:13:31 +00:00 committed by GitHub
parent 3328d4d3ab
commit a54874f0e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 3 additions and 38 deletions

View file

@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
go-version: [1.22.x, 1.23.x, 1.24.x, 1.25.x, 1.26.x]
go-version: [1.23.x, 1.24.x, 1.25.x, 1.26.x]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}

2
go.mod
View file

@ -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.22
go 1.23

4
mux.go
View file

@ -472,9 +472,7 @@ func (mx *Mux) routeHTTP(w http.ResponseWriter, r *http.Request) {
value := rctx.URLParams.Values[i]
r.SetPathValue(key, value)
}
if supportsPattern {
setPattern(rctx, r)
}
r.Pattern = rctx.routePattern
h.ServeHTTP(w, r)
return

View file

@ -1,16 +0,0 @@
//go:build go1.23 && !tinygo
// +build go1.23,!tinygo
package chi
import "net/http"
// supportsPattern is true if the Go version is 1.23 and above.
//
// If this is true, `net/http.Request` has field `Pattern`.
const supportsPattern = true
// setPattern sets the mux matched pattern in the http Request.
func setPattern(rctx *Context, r *http.Request) {
r.Pattern = rctx.routePattern
}

View file

@ -1,17 +0,0 @@
//go:build !go1.23 || tinygo
// +build !go1.23 tinygo
package chi
import "net/http"
// supportsPattern is true if the Go version is 1.23 and above.
//
// If this is true, `net/http.Request` has field `Pattern`.
const supportsPattern = false
// setPattern sets the mux matched pattern in the http Request.
//
// setPattern is only supported in Go 1.23 and above so
// this is just a blank function so that it compiles.
func setPattern(rctx *Context, r *http.Request) {}