`go fix ./...` in go1.22.4 is reporting invalid go version

110 views
Skip to first unread message

David Ševčík

unread,
Jun 12, 2024, 9:54:10 AMJun 12
to golang-nuts
Hello guys,
when I run locally or in CircleCI command `go fix ./...` it reports this error multiple times:
go fix ./...
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2
invalid -go=go1.22.0
exit status 2

When digging deeper, it shows that the underlying tool is reporting this error:
go tool fix -go=go1.22.0 .
invalid -go=go1.22.0

When I omit the path, it works:
go tool fix -go=go1.22 .
(no error, no output)

In source code, it looks like it uses standard go validation for the version:
https://github.com/golang/go/blob/b788e91badd523e5bb0fc8d50cd76b8ae04ffb20/src/cmd/fix/main.go#L75

I tried to run this validation in a test and it works:
func Test(t *testing.T) {
require.True(t, version.IsValid("go1.22.0"))
}
// Output
=== RUN   Test
--- PASS: Test (0.00s)
PASS
So I'm confused, why it fails.

Local machine:
Apple M3 Pro
macOS Sonoma (Version 14.5 (23F79))

Installed go is:
go version go1.22.4 darwin/arm64
In go.mod is:
go 1.22.0

toolchain go1.22.4

This tool fails also in the CircleCI, used image is:
cimg/go:1.22 where is probably also go1.22.4

Do anybody know why it's happening and how to fix it?
Looks like a bug to me 🤔

David Ševčík

unread,
Jun 13, 2024, 7:16:50 AMJun 13
to golang-nuts
Ok, I was searching in wrong branch, I found the cause, it's caused by the custom version parsing in the 1.22 branch, in the main it's fixed
Reply all
Reply to author
Forward
0 new messages