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: go modules in subfolders of VSCode folder are not recognized #37838

Closed
mback2k opened this issue Mar 13, 2020 · 6 comments
Closed

x/tools/gopls: go modules in subfolders of VSCode folder are not recognized #37838

mback2k opened this issue Mar 13, 2020 · 6 comments
Labels
Milestone

Comments

@mback2k
Copy link

@mback2k mback2k commented Mar 13, 2020

What version of Go are you using (go version)?

$ go version
go version go1.13.4 linux/amd64
golang.org/x/tools/gopls v0.3.3
    golang.org/x/tools/gopls@v0.3.3 h1:mTFqRDJQmpSsgDDWvbtGnSva1z9uX2XcDszSWa6DhBQ=

Does this issue reproduce with the latest release?

Unknown, as a golang 1.14 package is not available for Ubuntu Xenial.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/marc/.cache/go-build"
GOENV="/home/marc/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/mnt/c/Users/Marc/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.13"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.13/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build013358927=/tmp/go-build -gno-record-gcc-switches

What did you do?

I am using a Go project folder structure like this:

go-projects
├── npiperelay
│   ├── LICENSE
│   ├── npiperelay.go
│   ├── overlappedfile.go
│   ├── README.md
│   └── scripts
│       ├── docker-relay
│       ├── gpg-relay
│       ├── serial-relay
│       └── vmserial-connect
└── wsl-ssh-pageant
    ├── assets
    │   └── icon.ico
    ├── assets.go
    ├── azure-pipelines.yml
    ├── build.ps1
    ├── go.mod
    ├── go.sum
    ├── LICENSE
    ├── main.go
    ├── Readme.md

As you can see there is a go.mod file in the wsl-ssh-pageant project.

In Visual Studio Code I am opening the folder go-projects instead of the individual subfolders for reach project in order to quickly jump between them. You could think of it as my mono-repo-like approach with VSCode even though the individual projects are individual repos.

What did you expect to see?

I expected gopls to recognize the go.mod file in the wsl-ssh-pageant project.

What did you see instead?

Instead I am getting this error message:

You are neither in a module nor in your GOPATH. Please see https://github.com/golang/go/wiki/Modules for information on how to set up your Go project.

@gopherbot gopherbot added this to the Unreleased milestone Mar 13, 2020
@gopherbot gopherbot added the Tools label Mar 13, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Mar 13, 2020

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@gopherbot gopherbot added the gopls label Mar 13, 2020
@mback2k mback2k changed the title x/tools/gopls: <fill this in> x/tools/gopls: go modules in subfolders of VSCode folder are not recognized by gopls Mar 13, 2020
@mback2k mback2k changed the title x/tools/gopls: go modules in subfolders of VSCode folder are not recognized by gopls x/tools/gopls: go modules in subfolders of VSCode folder are not recognized Mar 13, 2020
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Mar 13, 2020

gopls currently doesn't support editing opening directories that are above a module. We will be working on fixing this for gopls/v0.5.0. A work-around is to add the root of the module to your workspace - in VS Code, that can be done by navigating to File -> Add Folder to Workspace. Sorry about the inconvenience, and we hope to have this fixed soon.

@stamblerre stamblerre closed this Mar 13, 2020
@mback2k
Copy link
Author

@mback2k mback2k commented Mar 13, 2020

@stamblerre Thanks for your feedback, but why is this issue closed if it is not already solved yet?

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Mar 13, 2020

We will be working on fixing this for gopls/v0.5.0.

This is an issue we are already aware of, and we have a number of issues related to it in the gopls/v0.5.0 milestone, so I closed this as a duplicate.

@myroid
Copy link

@myroid myroid commented Jun 29, 2020

It’s been almost 3 months, and it’s still not fixed.

@brandonbloom
Copy link

@brandonbloom brandonbloom commented Oct 7, 2020

Looks like there are some updates on this topic over here: #32394

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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