Skip to content

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

Closed
@findleyr

Description

@findleyr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.release-blocker

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions