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

cmd/go, x/mod: "invalid go version" message mentions old version format #61888

Closed
dominikh opened this issue Aug 9, 2023 · 22 comments
Closed
Labels
GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dominikh
Copy link
Member

dominikh commented Aug 9, 2023

When parsing an invalid go line in a go.mod, the error message says

go: errors parsing go.mod:
go.mod:3: invalid go version '1.22foo': must match format 1.23

but that's not strictly true, it doesn't have to match the 1.23 format anymore.

@seankhliao seankhliao added NeedsFix The path to resolution is known, but the work has not been done. GoCommand cmd/go labels Aug 9, 2023
@seankhliao
Copy link
Member

cc @bcmills

@jamietanna
Copy link

jamietanna commented Sep 8, 2023

What version of the go CLI was this with? I've hit this this morning when using gopls that's been compiled with a pre-1.21 go. The solution was to upgrade go.

@vincenthsh
Copy link

just came across this, to update vscode go tooling:

  1. Press Ctrl+Shift+P
  2. Select Go: Install/Update tools

or just to update golang language server:

go install golang.org/x/tools/gopls@latest

and you may Ctrl+Shift+P to restart language server

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/527897 mentions this issue: modfile: use new go version string format in error message

gopherbot pushed a commit to golang/mod that referenced this issue Sep 14, 2023
For golang/go#61888

Change-Id: If4056623471edb6fd99d45dcd8a0751d6a54ce1c
Reviewed-on: https://go-review.googlesource.com/c/mod/+/527897
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
@amrojjeh
Copy link

I just got this error message recently after I updated go. I updated gopls as well and that did not fix it. For now I've manually edited the version number to be 1.21 rather than 1.21.1

@optik-aper
Copy link

optik-aper commented Sep 27, 2023

I am also noticing this occurring in newly go mod init'd projects on fresh pull of gopls@latest. Manually editing the go version in go.mod allows the language server to restart without error. I'm using vim-go which utilizes YouCompleteMe for the LSP communication to gopls.

go version                                                                                             
go version go1.21.0 linux/amd64

gopls version                                                                                         
golang.org/x/tools/gopls v0.13.2
    golang.org/x/tools/gopls@v0.13.2 h1:Pyvx6MKvatbX3zzZmdGiFRfQZl0ohPlt2sFxO/5j6Ro=

@Seefooo
Copy link

Seefooo commented Oct 13, 2023

I am also running into this. Similar setup to @optik-aper:

go version go1.21.1 linux/amd64
golang.org/x/tools/gopls v0.13.2
    golang.org/x/tools/gopls@v0.13.2 h1:Pyvx6MKvatbX3zzZmdGiFRfQZl0ohPlt2sFxO/5j6Ro=

@andydotxyz
Copy link
Contributor

Possibly related to #63370?
There seems to be confusion to what version numbers the tools should support. Part of the challenge of introducing a new format and requiring it in the same release I think?

@let4be
Copy link

let4be commented Oct 27, 2023

For me fixing version in go.mod and go.work to 1.21 didn't resolve the issue :(
What am I missing?

@let4be
Copy link

let4be commented Oct 27, 2023

Hrm... should do this for all other modules in a workspace as well
Okay, changing all stuff to 1.21 resolved the issue

Is there currenlt no way to specify the version exactly, like 1.21.3?

simondeziel added a commit to simondeziel/lxd that referenced this issue Oct 31, 2023
Works around golang/go#61888

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel added a commit to simondeziel/lxd that referenced this issue Oct 31, 2023
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel added a commit to simondeziel/lxd that referenced this issue Oct 31, 2023
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel pushed a commit to simondeziel/lxd that referenced this issue Nov 1, 2023
This is to workaround golang/go#61888

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel added a commit to simondeziel/lxd that referenced this issue Nov 1, 2023
This is to workaround golang/go#61888

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel pushed a commit to simondeziel/lxd that referenced this issue Nov 1, 2023
This is to workaround golang/go#61888

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel added a commit to simondeziel/lxd that referenced this issue Nov 1, 2023
This is to workaround golang/go#61888

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel pushed a commit to simondeziel/lxd that referenced this issue Nov 2, 2023
This is to workaround golang/go#61888

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel added a commit to simondeziel/lxd that referenced this issue Nov 2, 2023
This is to workaround golang/go#61888

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel pushed a commit to simondeziel/lxd that referenced this issue Nov 2, 2023
This is to workaround golang/go#61888

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
@oussamaAbdelwahed
Copy link

just came across this, to update vscode go tooling:

  1. Press Ctrl+Shift+P
  2. Select Go: Install/Update tools

or just to update golang language server:

go install golang.org/x/tools/gopls@latest

and you may Ctrl+Shift+P to restart language server

After doing the steps above , you sometimes have to manually close and reopen vscode (even Ctrl+Shift+P then 'Reload Window' doesnt worked for me )

jiridanek added a commit to jiridanek/kubezoo that referenced this issue May 24, 2024
```
 + cd /home/runner/work/_temp/go/pkg/mod/sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20240522175850-2e9781e9fc60
+ GOBIN=/home/runner/work/kubezoo/kubezoo/bin go install ./
go: errors parsing go.mod:
/home/runner/work/_temp/go/pkg/mod/sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20240522175850-2e9781e9fc60/go.mod:3: invalid go version '1.22.0': must match format 1.23
```

This seems to be fixed by either using older envtest or newer go

* golang/go#61888
paboum added a commit to paboum/lnd that referenced this issue Jun 27, 2024
priyanshi-yb added a commit to yugabyte/yb-voyager that referenced this issue Aug 14, 2024
…h latest staticcheck package(#1633)

Go Run staticcheck is failing with the latest go/tools/cmd/staticcheck package https://github.com/dominikh/go-tools/releases/tag/2024.1 with an error -
```
go: honnef.co/go/tools/cmd/staticcheck@latest (in honnef.co/go/tools@v0.5.0): go.mod:3: invalid go version '1.22.1': must match format 1.23
```
which seems to be not working with the current go version we use, we might need to upgrade go (reference golang/go#61888 (comment)) but for now restricting the static check package to use the last release before the latest i.e. 2023.1.7 https://github.com/dominikh/go-tools/releases/tag/2023.1.7
burov added a commit to GoogleCloudPlatform/osconfig that referenced this issue Aug 20, 2024
google-oss-prow bot pushed a commit to GoogleCloudPlatform/osconfig that referenced this issue Aug 21, 2024
jessp01 added a commit to solworktech/zaje that referenced this issue Nov 25, 2024
go: golang.org/x/tools/cmd/goimports@latest (in golang.org/x/tools@v0.27.0): go.mod:3: invalid go version '1.22.0': must match format 1.23
in GH Actions.

See golang/go#61888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

16 participants