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:

  1. Create folder
  2. Create a.go:
    package main
    
    type whatever struct{}
    
  3. 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

2 thoughts on “x/tools/cmd/gopls: file is not part of package

  1. $ gopls version
    version v0.1.3-cmd.gopls, built in $GOPATH mode
    

    Even after git pull on master branch the message still occurs. Also in vim-go.

Comments are closed.