Skip to content
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

cmd/go: GO111MODULE=off is treated as as GODEBUG=default=go1.20 #71412

Open
UiP9AV6Y opened this issue Jan 23, 2025 · 5 comments
Open

cmd/go: GO111MODULE=off is treated as as GODEBUG=default=go1.20 #71412

UiP9AV6Y opened this issue Jan 23, 2025 · 5 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@UiP9AV6Y
Copy link

Go version

go version go1.23.4 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.4'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/src/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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2806843945=/tmp/go-build -gno-record-gcc-switches'

What did you do?

i am running an application which uses a net/http.ServeMux with pattern features introduced with golang1.22

(e.g. http.HandleFunc("/{$}" ... to handle only requests for GET / HTTP/XXX)

building the application with GO111MODULE=off causes the application to respond with 404 page not found for requests which would otherwise be handled when running the application with GO111MODULE=on.

i have provided a simple reproducer

What did you see happen?

GO111MODULE=off go run .

in another terminal

curl -s 'http://localhost:8080/%7B%24%7D'
ok
curl -s 'http://localhost:8080/{$}'
404 page not found
curl -s http://localhost:8080/
404 page not found

GO111MODULE=on go run .

in another terminal

curl -s 'http://localhost:8080/%7B%24%7D'
404 page not found
curl -s 'http://localhost:8080/{$}'
404 page not found
curl -s http://localhost:8080/
ok

the request against the /{$} path is expected to yield a 404; i have included it for the sake of completeness

%7B%24%7D is the URL encoded notation of {$}

What did you expect to see?

i was expecting the golang1.22 net/http changes to be available regardless of the use of GO111MODULE=off. AFAIK this environment variable affects the code lookup and the compiler's expectations about the project layout and location. i did not expect it to downgrade/disable any language features.

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Jan 23, 2025
@seankhliao seankhliao changed the title net/http: GO111MODULE=off changes behaviour of ServeMux cmd/go: GO111MODULE=off is treated as as GODEBUG=default=go1.20 Jan 23, 2025
@seankhliao
Copy link
Member

seankhliao commented Jan 23, 2025

currently the default godebugs come from the module, if a go directive isn't present, it assumes go1.20 (last version before godebug controls were introduced)
https://go.googlesource.com/go/+/refs/heads/master/src/cmd/go/internal/load/godebug.go#56

@UiP9AV6Y
Copy link
Author

thank you for the clarification but shouldn't this show up with go env too then?

GO111MODULE=off go env

GO111MODULE='off'
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.4'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD=''
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build58633166=/tmp/go-build -gno-record-gcc-switches'

GODEBUG is empty in my case

@UiP9AV6Y
Copy link
Author

posting the status-quo in case others stumble over the same issue. additional information can be found in the docs:
https://go.dev/doc/godebug

cat go.mod

module gomodules-http

go 1.23.4

GO111MODULE=off go list -f '{{.DefaultGODEBUG}}' .

asynctimerchan=1,gotypesalias=0,httplaxcontentlength=1,httpmuxgo121=1,httpservecontentkeepheaders=1,netedns0=0,panicnil=1,tls10server=1,tls3des=1,tlskyber=0,tlsrsakex=1,tlsunsafeekm=1,winreadlinkvolume=0,winsymlink=0,x509keypairleaf=0,x509negativeserial=1

@dr2chase
Copy link
Contributor

@matloob @samthanawalla
Not sure if this is WAI or a bug.

@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants