-
Notifications
You must be signed in to change notification settings - Fork 732
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
BrokenImport #2933
Comments
renaming all the other go.mod / go.sum files to go.mod.backup doesn't make the issue go away... so there's that. |
Work is in progress golang/go#57979. In the meantime, do any of the wiki suggestions on working with multiple modules resolve your issue? |
go workspaces seems to work (though I have no idea why the renamed subfolder still fails, if it's only one subfolder with a go module, so the ongoing work in 57979 might not fix this specific bug) edit: blog theme (hugo) had a go.mod in it, so that's another spot where go.mod's can randomly show up... but renaming everything to go.mod.backup and go.sum.backup except one ~/git/awesome/server/go.mod still fails - which is weird because recreating the same thing from scratch doesn't have that issue:
the from scratch example seems to work like how the issue with gopls describes (one and only one subfolder with a valid go.mod) |
@unusualevent sorry, I'm not sure I understand. In your example, I would expect |
@findleyr having ./helloworld/example as a subfolder in a larger repo (helloworld) as a go module does not work. |
When working with multiple modules, please create a If that doesn't work, please share the full directory structure you are trying to work in and where you have go.work and go.mod files, and their contents. Thank you for the repro case description in the original report, but I think it's missing exactly where go.work/go.mod/go.sum files are. Can you please provide the details? If you need more info about go workspace, I hope tutorials like https://go.dev/doc/tutorial/workspaces or blog post (https://go.dev/blog/get-familiar-with-workspaces) are helpful. |
I think I am affected by the same issue. All of a sudden, in all my Go projects, vscode shows all non-stdlib imports as BrokenImports, yet all my projects compile just fine. I do not have a single go.work file anywhere on my computer, just a bunch of normal Go projects that all have a go.mod/go.sum. I had no issues up until maybe a week ago. It seems I have to suddenly git clone every. single. package. that I depend on, i.e. $GOPATH/pkg is not used anymore, I seem to need the plain text source files in $GOPATH/src. EDIT: After digging more, it seems that this issue begins to happen when I add a folder to VSCode that contains multiple Go modules. Normally my Go projects have exactly 1 go.mod in them, in the root directory. But I also have one special Git repository that contains sub folders with go modules. VSCode always had issues with go.mod files in sub folders, which was a documented known issue. But the issue never bled into other Go projects in the same VSCode workspace. Now all of a sudden, the moment I add my multi-project repo to VSCode, all other Go projects are affected. To me this feels like a hefty regression in either VSCode or gopls. |
@xrstf this does indeed sound like a regression. gopls@v0.15.0 was in fact designed to simplify working in multi-module workspaces (and fix several bugs). What you're describing is a bug, not an intentional regression. Based on feedback on gopls@v0.15+ I don't think this issue is affecting a large number of users. However, we are investigating similar reports in golang/go#66145. I have not yet been able to reproduce with various types of multi-root workspaces. Can you please share the content of your settings.json? |
@xrstf some other questions:
Thanks. |
I am new to Go and therefore not sure if this is really multi-module related in my case, but running |
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.Go: Locate Configured Go Tools
command.Share the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file.Share all the settings with the
go.
or["go"]
orgopls
prefixes.^ the above instruction is imprecise, there's user settings, workspace settings, folder settings (and default settings)
Describe the bug
Possibly related to the "if there are multiple nested gomodules in the workspace folder, gopls doesn't work" thing.
what happens: vscode shows github.com/go-chi/chi doesn't exist, but
go build
works just fine.what should happen: vscode's go detection should work the same (or better than) the in-terminal detection.
Steps to reproduce the behavior:
go get
go build
for example:
Screenshots or recordings
If applicable, add screenshots or recordings to help explain your problem.
possibly related??
golang/go#57979 ("Confusingly, if there is only one module in a nested directory, gopls will work. But if there are two modules, gopls won’t work.")
#2124
#2761
#2607
does that mean I'd have to open ~/git/awesome/server and ~/git/awesome/server-rewrite as separate folders within the workspace?
That has (at least two) downsides:
The text was updated successfully, but these errors were encountered: