go version)?$ go version go version go1.13.4 linux/amd64
golang.org/x/tools/gopls v0.3.3
golang.org/x/tools/[email protected] h1:mTFqRDJQmpSsgDDWvbtGnSva1z9uX2XcDszSWa6DhBQ=
Unknown, as a golang 1.14 package is not available for Ubuntu Xenial.
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
I am using a Go project folder structure like this:
βββ 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.
I expected gopls to recognize the go.mod file in the wsl-ssh-pageant project.
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.
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.
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 Thanks for your feedback, but why is this issue closed if it is not already solved yet?
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.
Itβs been almost 3 months, and itβs still not fixed.
Looks like there are some updates on this topic over here: https://github.com/golang/go/issues/32394
Most helpful comment
goplscurrently doesn't support editing opening directories that are above a module. We will be working on fixing this forgopls/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 toFile -> Add Folder to Workspace. Sorry about the inconvenience, and we hope to have this fixed soon.