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

feat: go1.21.0 support (invalid Go version: "1.21.0") #1431

Closed
zztkm opened this issue Aug 9, 2023 · 4 comments
Closed

feat: go1.21.0 support (invalid Go version: "1.21.0") #1431

zztkm opened this issue Aug 9, 2023 · 4 comments
Labels

Comments

@zztkm
Copy link

zztkm commented Aug 9, 2023

feature request

I need to allow version syntax 1.N.P

problem

Since go 1.21.0, go mod init generates the following go.mod:

module example

go 1.21.0

If I run staticcheck in this state, I get the following error:

invalid Go version: "1.21.0"

FYI: https://go.dev/doc/toolchain#versions

my environment

❯ go version
go version go1.21.0 darwin/arm64

❯ staticcheck -version
staticcheck 2023.1.3 (v0.4.3)

❯ staticcheck -debug.version
staticcheck 2023.1.3 (v0.4.3)

Compiled with Go version: go1.21.0
Main module:
        honnef.co/go/tools@v0.4.3 (sum: h1:o/n5/K5gXqk8Gozvs2cnL0F2S1/g1vcGCAx2vETjITw=)
Dependencies:
        github.com/BurntSushi/toml@v1.2.1 (sum: h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=)
        golang.org/x/exp/typeparams@v0.0.0-20221208152030-732eee02a75a (sum: h1:Jw5wfR+h9mnIYH+OtGT2im5wV1YGGDora5vTv/aa5bE=)
        golang.org/x/mod@v0.7.0 (sum: h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=)
        golang.org/x/sys@v0.3.0 (sum: h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=)
        golang.org/x/tools@v0.4.1-0.20221208213631-3f74d914ae6d (sum: h1:9ZNWAi4CYhNv60mXGgAncgq7SGc5qa7C8VZV8Tg7Ggs=)

@zztkm zztkm added the needs-triage Newly filed issue that needs triage label Aug 9, 2023
@zztkm
Copy link
Author

zztkm commented Aug 9, 2023

If it were to be corrected, it would need to be corrected here

i, err := strconv.Atoi(s[2:])

@dominikh dominikh added bug and removed needs-triage Newly filed issue that needs triage labels Aug 9, 2023
@dominikh
Copy link
Owner

dominikh commented Aug 9, 2023

Fixed. A new patch release will be made tomorrow.

@ldez
Copy link
Contributor

ldez commented Aug 9, 2023

@dominikh I think the dots should be escaped:

regexp.MustCompile(`^(?:go)?1\.(\d+).*$`)

@dominikh
Copy link
Owner

dominikh commented Aug 9, 2023

@ldez You'd be correct, and I don't know how that slipped through — at some point it was escaped… It's not a big issue, though. The regex is already very lax, mostly being used to parse versions that have already been validated by Go during our use of go/packages. I'll fix it for the release, but it should work fine for the moment.

dominikh added a commit that referenced this issue Aug 17, 2023
Go versions in go.mod files can now look like "go1.21rc5" or "go1.21.0".
See https://go.dev/doc/toolchain#versions.

Closes: gh-1431
(cherry picked from commit ac367e4)
fnaranjo-vmw added a commit to cloudfoundry/csb-brokerpak-aws that referenced this issue Oct 9, 2023
Some make targets were failing with "invalid Go version".
This issue was reported and fixed in staticcheck's official repo
several months ago: dominikh/go-tools#1431

This commit also changed the way the module is invoked in Makefile
to not need to include this dependency as a dependency in go.mod.
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

3 participants