Repository navigation
Closed
Labels
Description
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)
Reacted by oldner and Andrey Bolonin
Activity
dominikh commentedon Aug 13, 2024
I'm failing to reproduce this. Are you sure that you're running the same
staticcheckexecutable both times?artyom commentedon Aug 13, 2024
Yes, the one installed with
go install honnef.co/go/tools/cmd/staticcheck@latest:artyom commentedon Aug 13, 2024
I unset
GOEXPERIMENT=rangefunclike so:Reinstalled:
And now it succeeds:
So it looks like the bug only happens withGOEXPERIMENT=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)[-] module requires at least go1.23.0, but Staticcheck was built with go1.23 (compile)[/-][+]GOEXPERIMENT breaks Go version detection[/+]dominikh commentedon Aug 13, 2024
Thank you, I can reproduce it now.
dominikh commentedon Aug 14, 2024
Barring any other issues, I'll cut a new release later today that includes this fix.
go/loader: handle experimental features in version detection
go/loader: handle experimental features in version detection