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/go/packages: use the correct go version for the analyzed project #68495

Open
hyangah opened this issue Jul 17, 2024 · 1 comment
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Jul 17, 2024

When the system Go version is newer than the GOTOOLCHAIN go version, we observed the x/tools/go/packages picks up the system Go version as the go version. This can cause the package to use the incompatible go list command. @matloob found this is because x/tools/internal/gocommand.GoVersion called by x/tools/go/packages.(*golistState).getGoVersion, uses GO111MODULE=off which prevents correct go version computation depending on toolchain switch.

This bug prevents gopls (v0.15.3, v0.16.0, v0.16.1) from operating with old go versions like go1.19 if the system Go version is newer. (e.g. using -pgo flag that doesn't exist in go1.19)

This will potentially break the future gopls versions if users rely on the GOTOOLCHAIN to switch to go versions and go/packages ends up using new go list flags that do not exist in the GOTOOLCHAIN version but exist in the system Go version.

We first need to understand why GoVersion uses GO111MODULE=off.

cc @golang/tools-team @matloob @findleyr

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jul 17, 2024
@gopherbot gopherbot added this to the Unreleased milestone Jul 17, 2024
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.17.0 Jul 17, 2024
@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants