vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

Use GOTOOLCHAIN=auto in gopls update logic

Open findleyr opened this issue 2 months ago • 2 comments

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 avatar Jun 22 '24 13:06 findleyr