$ go env GOVERSION
go1.26.0
$ go mod init test
go: creating new go.mod: module test
$ cat go.mod
module test
go 1.25.0
$ go mod edit -go=$(go env GOVERSION)
go mod: invalid -go option; expecting something like "-go 1.26.0"
go env GOVERSION is generally consistent with https://pkg.go.dev/go/version, which is nice, however the string used by go mod edit does not include the "go" prefix, making it incompatible.
It would be nice if this were made consistent. Internally, the toolchain already knows how to do this, I'm sure; it's just not very well exposed via the CLI.
I think the solution is for any CLI flag or argument which accepts a Go version to also accept the format with the "go" prefix, including go mod edit -go.
Note that the reverse issue also exists, i.e. go mod edit -json shows "Go": "1.25.0", which is again incompatible with https://pkg.go.dev/go/version. However, this is less of a pain point, at least for my scripting use cases.
go env GOVERSIONis generally consistent with https://pkg.go.dev/go/version, which is nice, however the string used bygo mod editdoes not include the "go" prefix, making it incompatible.It would be nice if this were made consistent. Internally, the toolchain already knows how to do this, I'm sure; it's just not very well exposed via the CLI.
I think the solution is for any CLI flag or argument which accepts a Go version to also accept the format with the "go" prefix, including
go mod edit -go.Note that the reverse issue also exists, i.e.
go mod edit -jsonshows"Go": "1.25.0", which is again incompatible with https://pkg.go.dev/go/version. However, this is less of a pain point, at least for my scripting use cases.