Skip to content

import/path: Go Method Based Routing Not Existing on Go go1.23.1 darwin/arm64 #69796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aghilann opened this issue Oct 7, 2024 · 4 comments
Closed

Comments

@aghilann
Copy link

aghilann commented Oct 7, 2024

Go version

go version go1.23.1 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/aghi/Library/Caches/go-build'
GOENV='/Users/aghi/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/aghi/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/aghi/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/aghi/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/aghi/GolandProjects/todo/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/0x/mnt5bhj17w3cwp4j6pxsp60c0000gn/T/go-build1231989599=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Try running

package main

import (
	"log"
	"net/http"
)

// Handler for POST requests to create a snippet.
func helloWorld(w http.ResponseWriter, r *http.Request) {
	_, err := w.Write([]byte("Hello, world!"))
	if err != nil {
		return
	}
}

func main() {
	mux := http.NewServeMux()

	// Use method-based routing for POST requests.
	mux.HandleFunc("GET /hello", helloWorld)

	log.Print("starting server on :4000")

	err := http.ListenAndServe(":4000", mux)
	log.Fatal(err)
}

and the server will be running, then visit http://localhost:4000/hello and you will see the 404 response. Occurs anytime I try to use Method bases routing, I verified using runtime as well I am running 1.23.

What did you see happen?

(base) aghi@Aghilans-MacBook-Pro todo % curl GET http://localhost:4000/hello
curl: (6) Could not resolve host: GET
404 page not found
(base) aghi@Aghilans-MacBook-Pro todo % 

What did you expect to see?

Hello World

@aghilann
Copy link
Author

aghilann commented Oct 7, 2024

Set version explicitly in go.mod to go 1.23

@aghilann aghilann closed this as completed Oct 7, 2024
@aghilann aghilann reopened this Oct 7, 2024
@aghilann
Copy link
Author

aghilann commented Oct 7, 2024

I'm puzzled by an issue. During runtime, logging would previously fail even when displaying '1.23'. However, running fmt.Println(runtime.Version()) shows 'go1.23.1' without any changes to the go.mod file. Nevertheless, method-based routing fails. Adding the necessary change to the go.mod file resolves the issue. I'm unsure why this is the case.

@seankhliao
Copy link
Member

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants