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

GOEXPERIMENT breaks Go version detection #1586

Closed
artyom opened this issue Aug 13, 2024 · 5 comments
Closed

GOEXPERIMENT breaks Go version detection #1586

artyom opened this issue Aug 13, 2024 · 5 comments
Labels

Comments

@artyom
Copy link

artyom commented Aug 13, 2024

test1 ¶ staticcheck -debug.version
staticcheck 2024.1 (0.5.0)

Compiled with Go version: go1.23.0 X:rangefunc
Main module:
	honnef.co/go/[email protected] (sum: h1:29uoiIormS3Z6R+t56STz/oI4v+mB51TSmEOdJPgRnE=)
Dependencies:
	github.com/BurntSushi/[email protected] (sum: h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=)
	golang.org/x/exp/[email protected] (sum: h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=)
	golang.org/x/[email protected] (sum: h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=)
	golang.org/x/[email protected] (sum: h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=)
	golang.org/x/[email protected] (sum: h1:SHq4Rl+B7WvyM4XODon1LXtP7gcG49+7Jubt1gWWswY=)
test1 ¶ go version
go version go1.23.0 darwin/arm64
test1 ¶ go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/artyom/Library/Caches/go-build'
GOENV='/Users/artyom/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT='rangefunc'
GOFLAGS='-ldflags=-w -trimpath'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/artyom/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/artyom/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/artyom/Library/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/artyom/Library/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/artyom/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/tmp/test1/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/lb/3rk8rqs53czgb4v35w_342xc0000gn/T/go-build3092433690=/tmp/go-build -gno-record-gcc-switches -fno-common'

To reproduce:

$ mkdir /tmp/test1
$ cd /tmp/test1

$ go mod init foo
$ cat go.mod
module foo

go 1.23.0

$ cat >main.go <<EOF
package main
func main() {}
EOF

$ staticcheck 
-: module requires at least go1.23.0, but Staticcheck was built with go1.23 (compile)
@artyom artyom added bug needs-triage Newly filed issue that needs triage labels Aug 13, 2024
@dominikh
Copy link
Owner

I'm failing to reproduce this. Are you sure that you're running the same staticcheck executable both times?

@artyom
Copy link
Author

artyom commented Aug 13, 2024

Yes, the one installed with go install honnef.co/go/tools/cmd/staticcheck@latest:

test1 ¶ go version -m $(which staticcheck)
/Users/artyom/go/bin/staticcheck: go1.23.0 X:rangefunc
	path	honnef.co/go/tools/cmd/staticcheck
	mod	honnef.co/go/tools	v0.5.0	h1:29uoiIormS3Z6R+t56STz/oI4v+mB51TSmEOdJPgRnE=
	dep	github.com/BurntSushi/toml	v1.4.1-0.20240526193622-a339e1f7089c	h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
	dep	golang.org/x/exp/typeparams	v0.0.0-20231108232855-2478ac86f678	h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=
	dep	golang.org/x/mod	v0.17.0	h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
	dep	golang.org/x/sync	v0.7.0	h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
	dep	golang.org/x/tools	v0.21.1-0.20240531212143-b6235391adb3	h1:SHq4Rl+B7WvyM4XODon1LXtP7gcG49+7Jubt1gWWswY=
	build	-buildmode=exe
	build	-compiler=gc
	build	-trimpath=true
	build	DefaultGODEBUG=asynctimerchan=1,gotypesalias=0,httpservecontentkeepheaders=1,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1
	build	CGO_ENABLED=1
	build	GOARCH=arm64
	build	GOEXPERIMENT=rangefunc
	build	GOOS=darwin
	build	GOARM64=v8.0


test1 ¶ /Users/artyom/go/bin/staticcheck  
-: module requires at least go1.23.0, but Staticcheck was built with go1.23 (compile)
1 test1 ¶ cat go.mod main.go 
module foo

go 1.23.0
package main
func main() {}

@artyom
Copy link
Author

artyom commented Aug 13, 2024

I unset GOEXPERIMENT=rangefunc like so:

test1 ¶ go env -u GOEXPERIMENT
test1 ¶ go env GOEXPERIMENT

Reinstalled:

test1 ¶ go install honnef.co/go/tools/cmd/staticcheck@latest

test1 ¶ go version -m $(which staticcheck) | grep GOEXPERIMENT
1 test1 ¶ 

And now it succeeds:

test1 ¶ staticcheck ; echo $?                                 
0

So it looks like the bug only happens with GOEXPERIMENT=rangefunc (not sure yet either env-dependent or how the binary was buit).

The bug only happens when running staticcheck built with GOEXPERIMENT=rangefunc (regardless of the env it then used in)

@dominikh dominikh changed the title module requires at least go1.23.0, but Staticcheck was built with go1.23 (compile) GOEXPERIMENT breaks Go version detection Aug 13, 2024
@dominikh
Copy link
Owner

Thank you, I can reproduce it now.

@dominikh
Copy link
Owner

Barring any other issues, I'll cut a new release later today that includes this fix.

dominikh added a commit that referenced this issue Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants