Open findleyr opened 1 week ago
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
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)
.
8121604559035734c9677d5281bbdac8b1c17a1e 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 https://github.com/golang/go/issues/68248#issuecomment-2198396157