Skip to content

net/http: http.ServerMux, paths ending in * wildcard are not recognized. #68856

Closed as not planned
@tatang26

Description

@tatang26

Go version

go version go1.23rc2 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/tatan/Library/Caches/go-build'
GOENV='/Users/tatan/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/tatan/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/tatan/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23rc2'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/tatan/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/tatan/code/playground/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/t_/vwcgfn5j3p7dy1y6t4fb1f740000gn/T/go-build1796478944=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

In Go 1.23, it appears that http.ServeMux is not interpreting correctly the * character as a wildcard in route patterns. Instead, * is being treated as a literal path segment, which leads to unexpected behavior. For instance, I have this route

r.HandleFunc("/public/*", assetsHandler)

And when I make a call like:

curl http://localhost:3000/public/image.jpeg

What did you see happen?

I expect the file is served in my web app

What did you expect to see?

I get a 404 page not found

but if I make a request like:

In Go.122 works well

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions