-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: degraded behavior on repositories containing multiple modules #59176
Comments
Thanks for this thoughtful issue. It sounds like you've correctly analyzed the problem: a go.work file is required until #57979 lands. Unfortunately, we can't revert experimentalWorkspaceModule at this point, nor do I think that is the correct course of action. If users want to work on multiple modules the same build, they should use a go.work file. If they want to work on multiple disconnected modules, gopls should do the right thing (which is #57979). We have undertaken a major rewrite of gopls' internals since reverting experimentalWorkspaceModule, to fix the scalability problems that are blocking #57979. At this point, the path forward is faster than the path backward. That error message is unfortunately poor, which is my fault. We should have at least fixed the error message before reverting experimentalWorkspaceModule. (FWIW, we have no data on how many users are using the experimentalWorkspaceModule setting). Given that v0.12.0 is still ~a month out, perhaps we should do a v0.11.1 release improving the error message. I will investigate if that would be possible. |
Sorry, just to be clear, in my previous comment I was assuming that the experimentalWorkspaceModule feature had been removed in [email protected], but my memory was incorrect. In fact that removal happened after v0.11.0 (https://go.dev/cl/458116). This was intentional, because we did not have time to otherwise improve the multi-module experience for v0.11.0. So, are you saying that the experience with gopls@master is degraded, relative to the experience with v0.11.0+experimentalWorkspaceModule? Or are you saying that multi-module support is degraded relative to working in GOPATH? I'm not trying to say there isn't a problem here: there is and it is our top priority, but fixing it is rather more complicated than one might guess. Our plan to do so is to fix the incremental performance cost of each workspace (#57987), and then have gopls automatically create new workspaces as files are opened (#57979). |
@findleyr This could have been a regression in the Go extension or Reverting my local environment back to Go 1.17 and Trying to bisect this back to current day - and wiping local go bin and other paths - I was unable to repro. Perhaps my IDE was using It's a serious regression, but the impact in my issue description is wrong barring another confounding variable. I've reset my Go environment twice now, and I cannot repro as long as I have |
@findleyr I did a survey of how users could experience What I think is markedly worse though, is that the errors users see don't direct users to a golden path. I would be happy to chat more or provide test cases. In the mean time, we're exploring how we can modify our
|
@AaronFriel thank you for that detailed analysis. We should check back in with this use-case as we improve error messages and implement #57979. At present we're focused on scalability improvements that we also view as critical for monorepos and/or multi-module workspaces. Removing experimentalWorkspaceModule support was an important simplification to allow us to make progress on this goal. Furthermore, experimentalWorkspaceModule was deemed not to be the correct solution for multi-module workspaces, because it hides the fact that users may be working with different dependencies than are deployed in production. That's not to say that gopls shouldn't just do the right thing when the user opens a Go file. It should, but it should use the same build list as the Go command run from that directory; if the user wants to work on multiple modules in the same logical build, they can use a go.work file. This is the motivation behind #57979. v0.12.0 should include much better error messages, with quick-fixes to add and/or update your go.work. This is #53880. True "zero-config" multi-module workspaces as described in #57979 are slated for v0.13.0 over the summer. I understand your point that this is a degraded experience from v0.11.0+experimentalWorkspaceModule. All I can say is that we had little evidence that anyone was actually using [5] just looks like a bug, or some sort of misconfiguration. The initial workspace load should populate the module cache for any missing imports. Go to definition for imports within the repository should succeed for any module in your go.work file. Can you say more about this setup? You have many modules in nested directories, and a go.work file that uses them all? |
Appreciate the status update and info. Would be very happy to contribute anything back here that would be helpful. Re: [5] No, this is for the use case that a user has inadvertently cloned the repository into a Go workspace but the go.work file does not reference the modules. The 0.12 quick fix should improve that use case by providing them with a solution. |
@findleyr This sounds like it could be related to either of the problems we identified yesterday: |
We have added quick-fixes to add missing modules to a go.work file (creating one if necessary). Furthermore, we have fixed several performance issues related to working with a go.work file containing many modules. For the [email protected] release, #57979 is the major feature. |
gopls version
go env
What did you do?
Cloned a multi-module repository, such as https://github.com/pulumi/pulumi-kubernetes into the correct location in GOPATH. (Or outside GOPATH, the behavior is the same either way.)
I then opened this directory in VS Code.
What did you expect to see?
I expected to see the Go modules for
/examples
,/provider
, and/sdk/go
"light up", with valid code completion and import information.What did you see instead?
All non-built-in imports yield broken import errors, e.g.:
Neither
go mod download
norgo get
nor any other command seems to rectify these.Editor and settings
Visual Studio Code 1.76.2
Go extension
golang.go
Additional information
This experience is materially worse than previous versions of Go, a serious regression for new users and even onboarding engineers into Go. Go workspaces appear to now be required for these use cases, however committing
go.work
files would result in our repositories overriding advanced users' workspace configurations.Would it be possible to revert removal of
experimentalWorkspaceModule
until the work in #57979 lands? There is a serious gap in usability. Any would-be contributor cloning a repository containing multiple Go modules and usinggopls
would encounter this, and the error message does not put users onto a golden path.Impact
This impacts approximately two hundred thousand modules on GitHub alone, per a GitHub Code Search showing over 200,000
go.mod
files in subdirectories:The text was updated successfully, but these errors were encountered: