8000 GOEXPERIMENT breaks Go version detection · Issue #1586 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content

GOEXPERIMENT breaks Go version detection #1586

Closed

Description

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

Compiled with Go version: go1.23.0 X:rangefunc
Main module:
	honnef.co/go/tools@v0.5.0 (sum: h1:29uoiIormS3Z6R+t56STz/oI4v+mB51TSmEOdJPgRnE=)
Dependencies:
	github.com/BurntSushi/toml@v1.4.1-0.20240526193622-a339e1f7089c (sum: h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=)
	golang.org/x/exp/typeparams@v0.0.0-20231108232855-2478ac86f678 (sum: h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=)
	golang.org/x/mod@v0.17.0 (sum: h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=)
	golang.org/x/sync@v0.7.0 (sum: h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=)
	golang.org/x/tools@v0.21.1-0.20240531212143-b6235391adb3 (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)

Activity

  1. dominikh commented on Aug 13, 2024

    @dominikh
    Owner

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

  2. artyom commented on Aug 13, 2024

    @artyom
    SponsorAuthor

    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() {}
    
  3. artyom commented on Aug 13, 2024

    @artyom
    SponsorAuthor

    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)

  4. changed the title [-] module requires at least go1.23.0, but Staticcheck was built with go1.23 (compile)[/-] [+]GOEXPERIMENT breaks Go version detection[/+] on Aug 13, 2024
  5. dominikh commented on Aug 13, 2024

    @dominikh
    Owner

    Thank you, I can reproduce it now.

  6. dominikh commented on Aug 14, 2024

    @dominikh
    Owner

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

  7. added a commit that references this issue on Aug 14, 2024
    94a1600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0