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

x/tools/gopls: set types.Config.GoVersion based on go.mod #50688

Closed
findleyr opened this issue Jan 19, 2022 · 3 comments
Closed

x/tools/gopls: set types.Config.GoVersion based on go.mod #50688

findleyr opened this issue Jan 19, 2022 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. release-blocker Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

In Go 1.18, the GoVersion was added to go/types.Config (proposal: #46648). This field configures the Go language version, as would be passed to the compiler via -lang, and read by the Go tool from the go directive in the go.mod.

This means that gopls can now match compiler type-checking errors exactly, by setting Config.GoVersion based on the applicable go.mod file. We should do this for 1.18, as it will be common for users to write generic code with gopls, only to be surprised when they get errors from the go command due to their go.mod file.

This is also a critical component of using gopls built with a recent version of Go to target building at an older Go version.

@gopherbot 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 Jan 19, 2022
@gopherbot gopherbot added this to the Unreleased milestone Jan 19, 2022
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.8.0 Jan 19, 2022
@findleyr
Copy link
Contributor Author

findleyr commented Feb 4, 2022

As a bonus, it would be cool to offer a quick-fix that updates the go.mod file to the required version. That is a much lower priority.

@findleyr
Copy link
Contributor Author

findleyr commented Feb 4, 2022

CC @hyangah @heschi

Hana was (quite wisely) concerned about users bumping up against version skew pain with 1.18. This is one part fixing that.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/383394 mentions this issue: internal/lsp/cache: set types.Config.GoVersion

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. release-blocker Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants