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

Closed
katiehockman opened this issue Apr 22, 2020 · 11 comments
Closed
Labels
Documentation FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@katiehockman
Copy link
Contributor

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 Issues related to the Go language server, gopls. label Apr 22, 2020
@gopherbot gopherbot added this to the Unreleased milestone Apr 22, 2020
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Apr 22, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 Apr 22, 2020
@stamblerre
Copy link
Contributor

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
Contributor Author

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

@stamblerre
Copy link
Contributor

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

@hyangah
Copy link
Contributor

hyangah commented Apr 22, 2020

Is $HOME/godev a binary or directory?

@katiehockman
Copy link
Contributor Author

It's a directory

@hyangah
Copy link
Contributor

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
Contributor Author

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

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
Contributor Author

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
@stamblerre stamblerre modified the milestones: gopls/v0.5.0, gopls/v1.0.0 Jul 21, 2020
FiloSottile added a commit to golang/vscode-go that referenced this issue Aug 18, 2020
@gopherbot
Copy link

Change https://golang.org/cl/249057 mentions this issue: docs: add stdlib.md

gopherbot pushed a commit to golang/vscode-go that referenced this issue Aug 20, 2020
Updates golang/go#38603

Change-Id: Ie67fb8456178cbcbbbe18fd38c6b74f83c84222b
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/249057
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@pjweinb pjweinb self-assigned this Sep 6, 2020
@stamblerre stamblerre changed the title x/tools/gopls: special setup required for working with the std library x/tools/gopls: document setup required for working with the std library Sep 9, 2020
@gopherbot
Copy link

Change https://golang.org/cl/253297 mentions this issue: x/gools/gopls: document settings for working on source distribution

@stamblerre stamblerre removed this from the gopls/v1.0.0 milestone Sep 10, 2020
@golang golang locked and limited conversation to collaborators Sep 10, 2021
@rsc rsc unassigned pjweinb Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants