If you want to default GODEBUG=httpmuxgo121=0. One way to do this is to set go1.22.0 on the go line of go.mod, or add a //go:debug httpmuxgo121=0 to the go file of the main package.
On Monday, February 12, 2024 at 3:09:38 PM UTC+8 qiulaidongfeng wrote: > Starting with go1.21, GODEBUG is set by default according to the go line > of go.mod. > > On Monday, February 12, 2024 at 11:47:31 AM UTC+8 xab3r wrote: > >> Hello there >> >> I've just tried new routing patterns in Go 1.22.0, and I noticed that I >> have to set httpmuxgo121=0 explicitly in order to get it enabled. When the >> release notes say to "set httpmuxgo121=1 to restore the old behaviour". So, >> as I understand it, by default, it should work with new path patterns. >> >> This is the handler >> ``` >> mux.HandleFunc("GET /hello", func(w http.ResponseWriter, r *http.Request) >> { >> fmt.Fprint(w, "Hello") >> }) >> ``` >> >> So this piece of code is not gonna work if I run it like this >> `$ go run main.go` >> The server responds with 404. >> >> But it's working as expected when I explicitly set httpmuxgo121 to 0 >> `$ GODEBUG=httpmuxgo121=0 go run main.go` >> >> Also, I compiled go from sources with extra logs and `use121` variable >> https://github.com/golang/go/blob/master/src/net/http/servemux121.go#L23 >> is set to 1 by default, when I don't specify it explicitly via the ENV >> variable. >> >> What's the correct behaviour? Any clues are welcome >> >> Thanks >> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/9cf2393a-cbd6-4a47-8a55-6fb8fb958b1fn%40googlegroups.com.