go-langserver doesn't work when editing a package outside of the gopath
See original issue in vscode-go https://github.com/Microsoft/vscode-go/issues/886
Any updates on this?
cc @slimsag
@keegancsmith what are your thoughts on this issue? I looked into the referenced issue and I can imagine two scenarios:
- Opening a project outside $GOPATH, but having a $GOPATH set.
- 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.
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.
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.