go: x/tools/cmd/gopls: file is not part of package
Reproduces with gopls@master and gopls@latest:
golang.org/x/tools/gopls v0.1.0
golang.org/x/tools/gopls@v0.1.2-0.20190708203411-c8855242db9c h1:qFHl9H1pFOvam5c7rRNiSVPuASu5sS/VNZUj7KNAyGI=
and
$ gopls version
golang.org/x/tools/gopls v0.1.0
golang.org/x/tools/gopls@v0.1.1 h1:mU/O8r53RjzdZfkqmFOX4iEt8PJxTPXyLdiuQNa27OE=
Steps to reproduce:
- Create folder
- Create a.go:
package main type whatever struct{} - Create b.go:
package main import "fmt" func main() { w := whatever{} fmt.Println("whatever", w) }
This compiles and runs fine, but in vscode with gopls I get a red squiggly over package with the error:
file:///usr/local/google/home/deklerk/workspace/interview-questions/foo/b.go is not part of a package LSP
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 17
- Comments: 38 (16 by maintainers)
Even after
git pullon master branch the message still occurs. Also invim-go.@stamblerre Ok, i’ve just moved my project to another directory (it was in GOPATH/src originally) and then have updated my imports. It seems to solve the issue. My
GOMODis no longer set toNULL.i didn’t know that module support is enabled only when the current directory is outside GOPATH/src… I suppose that was the source of the problem with GOPLS.
Reloading the window without removing the directories resolves the issue until another directory is added.
I got this error too. This error has gone when I reopen vscode, but it will come out at an other new open file.