-
Notifications
You must be signed in to change notification settings - Fork 763
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
gopls was not able to find modules in your workspace. #2534
Comments
@sfpotato Could you provide some more information about your setup? What directory do you have open and where are the relevant go.mod and go.work files? |
I have a project located at
|
@sfpotato which directory did you open as your workspace? |
FWIW this does not reproduce for me, using the suggested layout for |
Oh. I see, |
Sorry for bumping an old issue, but am I right in believing that this means that if your project looks like the following, you can't open the root of the project in VSCode (
|
@0xdeafcafe in that case you could move your go.work to the Note that we're trying to fix this. I just published a design to mitigate this configuration problem: golang/go#57979 |
Ah setting the GOWORK is a great idea, that totally skipped my mind. I'll give that a go tomorrow, cheers! |
I believe for some of the people this issue deserve an easier fix. What does it mean to have
These two commands open VSCode in the project inside of a module. |
Kinda sucks that I need to open my IDE workplace to the directory where the go.work file resides. So when working on multiple project, I need to have multiple windows open instead of just being able to have them all in one. Feels more like an impediment to an efficient workflow. |
@svitan0k golang/go#57979 is my main priority for the rest of this year. Please stay tuned. |
@findleyr , Would this (golang/go#57979) fix if my workspace looks like below? golang/go#45184 (comment) Any suggestion to fix this temporarily ? |
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.Run
gopls -v version
to get version of Gopls from the VS Code integrated terminal.golang.org/x/tools/gopls v0.10.1
golang.org/x/tools/[email protected] h1:JoHe17pdZ8Vsa24/GUO8iTVTKPh0EOBiWpPop7XJybI=
github.com/BurntSushi/[email protected] h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/google/[email protected] h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/[email protected] h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
golang.org/x/exp/[email protected] h1:7Xs2YCOpMlNqSQSmrrnhlzBXIE/bpMecZplbLePTJvE=
golang.org/x/[email protected] h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
golang.org/x/[email protected] h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/[email protected] h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/[email protected] h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/[email protected] h1:KBm+UwBaO/tdQ35tfGvxH1FUCiXRg4MoTzkznsdeab8=
golang.org/x/[email protected] h1:KaYZQUtEEaV8aVADIHAuYBTjo77aUcCvC7KTGKM3J1I=
honnef.co/go/[email protected] h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
mvdan.cc/[email protected] h1:avhhrOmv0IuvQVK7fvwV91oFSGAk5/6Po8GXTzICeu8=
mvdan.cc/xurls/[email protected] h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.19
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.Go: Locate Configured Go Tools
command.GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE="">
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."go.formatTool": "gofmt", "go.lintOnSave": "workspace", "go.lintTool": "golint",
Describe the bug
My project can pass
go build
, but extension report some error, likegopls was not able to find modules in your workspace. When outside of GOPATH, gopls needs to know which modules you are working on.
could not import packageName (cannot find package "packageName" in any of /usr/local/go/src packageName (from $GOROOT)
And I use
go.work
to include all directory containgo.mod
to solve multi modules, these error report still exist.Screenshots or recordings
If applicable, add screenshots or recordings to help explain your problem.
The text was updated successfully, but these errors were encountered: