go-langserver icon indicating copy to clipboard operation
go-langserver copied to clipboard

go-langserver doesn't work when editing a package outside of the gopath

Open keegancsmith opened this issue 8 years ago • 5 comments

See original issue in vscode-go https://github.com/Microsoft/vscode-go/issues/886

keegancsmith avatar Apr 18 '17 11:04 keegancsmith

Any updates on this?

mattoni avatar May 06 '17 17:05 mattoni

cc @slimsag

ramya-rao-a avatar Jun 05 '17 17:06 ramya-rao-a

@keegancsmith what are your thoughts on this issue? I looked into the referenced issue and I can imagine two scenarios:

  1. Opening a project outside $GOPATH, but having a $GOPATH set.
  2. Opening a project outside $GOPATH, but having no $GOPATH set.

I don't think we can support the latter case feasibly because of our reliance on $GOPATH/pkg now, so I assume this issue is just about supporting case one above.

I tried it out just now on github.com/gorilla/mux outside my $GOPATH, and hover/definition work OK with the godef-based implementation. But find all references and symbol search (#Router in command palette) do not seem to be working correctly.

emidoots avatar Jun 29 '17 08:06 emidoots

I think hover/def didn't work before your godef change. Just that working may be sufficient.

The workspace operations won't really work, since in general we need to know the package name a file lives in, and without a GOPATH we don't. However, we can do best effort for */symbol since all that really relies on is parsing the AST. For references I don't think we could reasonably support that without knowing the real package name for a file. Technically we could support references within the same package, but not sure the cost of implementing that is worth it.

keegancsmith avatar Jun 29 '17 15:06 keegancsmith

A more useful thing we could do is warn the user they are outside a GOPATH, and possibly provide an action to autoconfigure (find /src/ in a parent directory). I think that would have to be done in the extension, rather than in server.

keegancsmith avatar Jun 29 '17 15:06 keegancsmith