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/gopls: switch default to -mod=readonly #41437

stamblerre opened this issue Sep 16, 2020 · 2 comments

x/tools/gopls: switch default to -mod=readonly #41437

stamblerre opened this issue Sep 16, 2020 · 2 comments


Copy link

@stamblerre stamblerre commented Sep 16, 2020

In CLs 253799 and 254756, @heschik switched to explicitly using -mod=mod to preserve the current behavior of gopls with Go 1.16. Since -mod=mod will be deprecated, we need an alternative approach for the future.

A proposed solution has been to run go mod tidy before gopls runs go/packages.Load. This can be done with -modfile or in the temporary workspace module. This way, we preserve the existing behavior that allows users to edit modules that don't compile, but we still offer go mod tidy diagnostics. These diagnostics should be upgraded to errors (with Go 1.16).

/cc @jayconrod @findleyr

@stamblerre stamblerre added this to the gopls/v1.0.0 milestone Sep 16, 2020
Copy link
Contributor Author

@stamblerre stamblerre commented Sep 16, 2020

Another thing: Our model of textual updates to the go.mod does not allow for analogous updates to the go.sum, so we should use go commands instead of edits wherever possible.

@stamblerre stamblerre added this to Critical in gopls/v1.0.0 Sep 16, 2020
Copy link

@gopherbot gopherbot commented Oct 1, 2020

Change mentions this issue: gopls: add a test that mirrors govim's -mod=readonly test

gopherbot pushed a commit to golang/tools that referenced this issue Oct 2, 2020
This isn't strictly necessary, but we've broken it a number of times,
and it's easier to have a regtest for it. When golang/go#41437 is resolved, we
might consider making this a -mod=mod test or something.

Also, added a wrapper for RunGoCommand.

Change-Id: I75db585549d84dacde9d3efbc6e02a7ba4e005aa
Reviewed-by: Heschi Kreinick <>
Run-TryBot: Rebecca Stambler <>
gopls-CI: kokoro <>
TryBot-Result: Go Bot <>
Trust: Rebecca Stambler <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.