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/cmd/gopls: fails to detect local package in import #32733

Closed
brendensoares opened this issue Jun 21, 2019 · 3 comments
Closed

x/tools/cmd/gopls: fails to detect local package in import #32733

brendensoares opened this issue Jun 21, 2019 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@brendensoares
Copy link

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

$ go version
go version go1.12 darwin/amd64

Does this issue reproduce with the latest release?

Yes. With GOPATH built version (version v0.1.0-cmd.gopls, built in $GOPATH mode) as well as the Go Module built version:

$ gopls version
golang.org/x/tools/cmd/gopls v0.1.0-cmd.gopls
    golang.org/x/tools@v0.0.0-20190621195816-6e04913cbbac h1:MQEvx39qSf8vyrx3XRaOe+j1UDIzKwkYOVObRgGPVqI=

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/brendensoares/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/brendensoares/.gvm/pkgsets/go1.12/global"
GOPROXY=""
GORACE=""
GOROOT="/Users/brendensoares/.gvm/gos/go1.12"
GOTMPDIR=""
GOTOOLDIR="/Users/brendensoares/.gvm/gos/go1.12/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/tj/xht24r711bn6clhjkvtr76v00000gq/T/go-build968408658=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Setup local Go Module
    1.1. create local git repo in folder ./testx
    1.2. run go mod init github.com/org/testx in ./testx
    1.3. add ./testx/reporter/reporter.go
    1.4. add cli folder with main.go that imports github.com/org/testx/reporter
  2. view ./testx/cli/main.go in VS Code with Go extension using gopls

Project Structure:

testx/
  cli/
    main.go
  reporter/
    reporter.go
  go.mod

What did you expect to see?

No error which is what I see when using the non-LPS go tools with the VS Code Go extension.

What did you see instead?

The import line for github.com/org/testx/reporter is highlighted as an error. VS Code Output for gopls shows:

[Trace - 1:05:05 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/brendensoares/Developer/testx/cli/main.go","diagnostics":[{"range":{"start":{"line":5,"character":1},"end":{"line":5,"character":51}},"severity":1,"source":"LSP","message":"could not import github.com/org/testx/reporter (no parsed files for package github.com/org/testx/reporter)"}]}

Notes

@gopherbot gopherbot added this to the Unreleased milestone Jun 21, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jun 21, 2019
@stamblerre
Copy link
Contributor

Does the error persist or does it go away after some amount of time? Did you open VSCode with testx as the root directory?

@stamblerre stamblerre added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed gopls-imports labels Jun 28, 2019
@brendensoares
Copy link
Author

@stamblerre I believe I fixed it by making testx the root directory aka workspace folder in VS Code. Further, by adding testx as a 2nd workspace folder the error is resolved.

I was assuming gopls would traverse the path tree to find the "missing" package. Is that a wrong assumption? Clearly, that's not what it does, but should it?

PS - I'm excited to be able to try gopls Thanks for all your hard work on this OSS!

@stamblerre
Copy link
Contributor

Glad you were able to get this to work! This is a current limitation of gopls that we are tracking here: #32394.

@golang golang locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants