Skip to content

staticcheck: Fails with Go 1.24: internal error in importing ... (unsupported version: 2) #1627

@stefanb

Description

@stefanb

While testing Go 1.24 (rc1 and rc2) in

I noticed staticcheck is failing with a simple test from homebrew formula staticcheck.rb, reproduced below:

$ go1.24rc2 version
go version go1.24rc2 darwin/arm64

$ go1.24rc2 run honnef.co/go/tools/cmd/staticcheck@latest .
-: internal error in importing "internal/byteorder" (unsupported version: 2); please report an issue (compile)
-: internal error in importing "internal/cpu" (unsupported version: 2); please report an issue (compile)
-: internal error in importing "internal/goarch" (unsupported version: 2); please report an issue (compile)
-: internal error in importing "internal/goos" (unsupported version: 2); please report an issue (compile)
-: internal error in importing "math/bits" (unsupported version: 2); please report an issue (compile)
exit status 1

$ go1.24rc2 run honnef.co/go/tools/cmd/staticcheck@latest -debug.version
staticcheck 2024.1.1 (0.5.1)

Compiled with Go version: go1.24rc2
Main module:
        honnef.co/go/tools@v0.5.1 (sum: h1:4bH5o3b5ZULQ4UrBmP+63W9r7qIkqJClEA9ko5YKx+I=)
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=)

Same test with go 1.23 works fine:

$ go version
go version go1.23.5 darwin/arm64

$ go run honnef.co/go/tools/cmd/staticcheck@latest .
main.go:6:2: should merge variable declaration with assignment on next line (S1021)
exit status 1

$ go run honnef.co/go/tools/cmd/staticcheck@latest -debug.version
staticcheck 2024.1.1 (0.5.1)

Compiled with Go version: go1.23.5
Main module:
        honnef.co/go/tools@v0.5.1 (sum: h1:4bH5o3b5ZULQ4UrBmP+63W9r7qIkqJClEA9ko5YKx+I=)
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=)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions