You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As suggested by @matta in #68248, we should warn when the version of Go used to compile gopls is older than the language version implied by the go.mod file. A diagnostic on the go directive of the go.mod file probably suffices.
FWIW, I reported a similar issue in staticcheck. There, the fix to build with go1.23rc1 worked as well.
@dominikh also added code to staticcheck that will report an error if the tool is used on a go module requiring versions of go newer than what the tool was built with. gopls could consider a similar check.
The text was updated successfully, but these errors were encountered:
gopherbot
added
Tools
This label describes issues relating to any tools in the x/tools repository.
gopls
Issues related to the Go language server, gopls.
labels
Jul 1, 2024
Note that Staticcheck primarily has its own logic for this to produce better error messages. go/types already complains when the asked-for language version is newer than the version of go/types, but in Go 1.22, the error message read package requires newer Go version go1.23. Starting with Go 1.23, it seems to produce a better error message: /home/dominikh/prj/src/example.com/foo.go:3:1: package requires newer Go version go1.24 (application built with go1.23).
8121604 seems to be the commit that improved the message.
Will a diagnostic in go.mod be enough? In my experience, "show all workspace diagnostics" is not consistently supported (or used) in editors. They show diagnostics only for the files the editor has opened.
In the case of #68248, I built with go1.23rc1 on the command line with go build ./... and saw all was well, then opened up a .go file in the project and saw the diagnostic from gopls. At that point, I did not open go.mod to check for additional diagnostics there.
In @dominikh's example above, maybe the error would appear for every file, which would cover it, I think.
As suggested by @matta in #68248, we should warn when the version of Go used to compile gopls is older than the language version implied by the go.mod file. A diagnostic on the go directive of the go.mod file probably suffices.
Originally posted by @matta in #68248 (comment)
The text was updated successfully, but these errors were encountered: