I was trying out some features of net/http package that was introduce in version 1.22. But I was using Go version 1.23.1
It was simple net/http path parameter with request.PathValue()
func main() {
router := http.NewServeMux()
router.HandleFunc("GET /item/{id}", func(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("id")
w.Write([]byte("Hello World ID: " + id))
})
server := http.Server{
Addr: ":8000",
Handler: router,
}
server.ListenAndServe()
}
But it did not work, it return 404 page not found
even though I followed the tutorial exactly. After a few tries, I change to Go version 1.22.7 instead and it worked.
Why does this features works in Go 1.22.7 but not in 1.23.1?
I looked at the version release date of net/http, both 1.22.7 and 1.23.1 were released on same day 5th Sep, 2024.
What was the reason for Go having version 1.22.7 and 1.23.1 ?
3