-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
This is an umbrella issue for visibility. We plan to change the default gopls behavior to allow network usage whenever "reinitializing" the workspace (which happens whenever a go.mod or go.work file is saved).
Currently, gopls only allows network usage during the initial workspace load. In all subsequent go command invocations, it sets GOPROXY=off. The original rationale for this is #38462, which was reporting poor behavior without internet because gopls uses the go command to compute go mod tidy diagnostics. To fix this, we set GOPROXY=off while running go mod tidy. However, at the time, any typing in a go.mod file would trigger a reinitialization, so it was decided to also disable network when reinitializing.
But this can lead to a confusing user experience, in part because the GOPROXY=off error message leaks, and in part because this is an example where restarting gopls can lead to a different state (because redo-ing the initial workspace load will allow network and fix problems).
Specifically, we have at least the following open issues:
- x/tools/gopls: On ANY network error, error says
GOPROXY=off#53676, where the "GOPROXY=off" error leaks to the user and it is very confusing (because the user didn't set GOPROXY=off). - x/tools/gopls: gopls doesn't recover easily if initial workspace loading fails #47540, where gopls cannot recover from a failed initial workspace load
Now that we only reinitialize on a go.work or go.mod file save, reinitialization should be infrequent. We should allow network, so that reinitialization has the same result as the initial workspace load.