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/gopls: special setup required for working with the std library #38603

Open
katiehockman opened this issue Apr 22, 2020 · 9 comments
Open

x/tools/gopls: special setup required for working with the std library #38603

katiehockman opened this issue Apr 22, 2020 · 9 comments

Comments

@katiehockman
Copy link
Member

@katiehockman katiehockman commented Apr 22, 2020

Find All References in VSCode is only able to find references within the same package. For example, clicking Find All References for pkix.Name in go/src/crypto/x509/pkix/pkix.go only finds 7 references to the type, although if you use search you can see there are several more than that.

settings.json:
{
"go.alternateTools": {
"go": "~/godev"
},
"go.toolsGopath": "~/.vscode/godev",
"html.format.enable": false,
"editor.codeActionsOnSave": {
"source.organizeImports": false
},
"gopls": {
"env": {
"PATH": "$HOME/godev:$PATH",
},
},
}

gopls version
golang.org/x/tools/gopls 0.4.0
golang.org/x/tools/gopls@v0.4.0 h1:G4+YP9kaV4dJb79J5MobyApxX493Qa6VoiTceUmxqik=

LMK if you need any logs.

@katiehockman katiehockman added the gopls label Apr 22, 2020
@gopherbot gopherbot added this to the Unreleased milestone Apr 22, 2020
@gopherbot gopherbot added the Tools label Apr 22, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 Apr 22, 2020
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Apr 22, 2020

What was the directory that you opened in VS Code? Right now, we limit the scope of references to the workspace root.

@katiehockman
Copy link
Member Author

@katiehockman katiehockman commented Apr 22, 2020

I opened it in go/src, so the other packages are within this workspace

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Apr 22, 2020

Ok, thanks for confirming! I'll take a look.

@hyangah
Copy link
Contributor

@hyangah hyangah commented Apr 22, 2020

Is $HOME/godev a binary or directory?

@katiehockman
Copy link
Member Author

@katiehockman katiehockman commented Apr 22, 2020

It's a directory

@hyangah
Copy link
Contributor

@hyangah hyangah commented Apr 22, 2020

But it is used for "go.alternateTools" which should be the path to the executable I think.

Can you please provide the output of "Go: Locate Configured Go Tools" (find from the command palette) and the beginning of the gopls log that prints out the go env results.

@katiehockman
Copy link
Member Author

@katiehockman katiehockman commented Apr 22, 2020

Ah! Yep that was it. Thank you.

Is this all documented somewhere? It's still pretty difficult to work in the standard library, and this just silently failed partially, without giving any error message.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Apr 22, 2020

The docs for "go.alternateTools" should pop up when you add that configuration:

Screen Shot 2020-04-22 at 7 33 04 PM

I'm surprised that that fixed the issue (unless you are using Go Nightly) because the fix for microsoft/vscode-go#3163 hasn't been released yet, and you have the workaround in your settings.

@katiehockman
Copy link
Member Author

@katiehockman katiehockman commented Apr 23, 2020

I was working with @FiloSottile on this config (I borrowed it from him) so I wasn't very familiar with all of these settings. He helped me set this up because I was unaware that I needed to redirect gopls to a different goroot when working in the standard library. As far as I know, this isn't in the official docs?

I don't think I'm running Go nightly, and not sure how to check, but can investigate if needed!

I'm mostly hoping for some documentation about how to set up gopls to work with the standard library, since it was very non-obvious to me (everything was working great, except for a few features that silently failed - like Find References).

@katiehockman katiehockman changed the title x/tools/gopls: unable to find references in other packages x/tools/gopls: special setup required for working with the std library Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.