golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.78k stars 727 forks source link

Use GOTOOLCHAIN=auto in gopls update logic #3430

Open findleyr opened 6 days ago

findleyr commented 6 days ago

Add described in golang/go#65917, once Go 1.23 is out we plan to update the gopls go.mod file to say go 1.23.0, meaning that building gopls will require a 1.23 toolchain. Thanks to toolchain upgrades, this will be handled automatically for most users of Go 1.21+.

However, a concern raised on that issue is that some users have GOTOOLCHAIN=local set in their Go environment. Notably, this is set by default in some Linux distributions, such as Fedora.

I believe we are adding knowledge of gopls' build matrix into VS Code. We should also consider the value of go env GOTOOLCHAIN. If local, and the Go version is less than the required build version, we have two options:

  1. Install gopls with an explicit GOTOOLCHAIN=auto.
  2. Don't install gopls, and warn the user that they must install gopls manually or set GOTOOLCHAIN=auto in their VS Code environment.

I think 2 is best. If the user (or distro) has set GOTOOLCHAIN=local, I think we should treat that as a statement that they don't want toolchain upgrades. On the other hand, it seems likely that most users in this scenario are unaware that their distro has this default, and so by failing to upgrade gopls we are causing additional work for them. Nevertheless, (2) seems most conservative, and once users have updated their environment the upgrades will proceed normally in the future.

Another concern is that users may have set GOTOOLCHAIN=local because they don't want go list (implicitly run by gopls) to install toolchains. If we do decide to go with route (1), it should only be for the gopls install, not for the gopls session.

findleyr commented 6 days ago

@hyangah I put this in the v0.42 milestone, but the goal should just be to land this by mid-august, when we plan the gopls@v0.17.0 release. Please re-milestone as appropriate.

findleyr commented 1 day ago

Decision: VS Code is going to set GOTOOLCHAIN=auto so that the toolchain upgrades work as expected.