-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: support module-local references #32869
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
Comments
Could you provide more information about this issue? Does this happen with all identifiers or only certain ones? |
Find all references only supports in package references right now, so if the uses are in a different package, it will not be able to find them. |
@suzmue Yes it works only in a single package, thanks. Maybe it make sense to link this issue to gopls wiki Known Issues as this behaviour is a bit confusing. |
same as me |
Also seeing this (see: microsoft/vscode-go#2665) |
I just learned that [outside gopls], if you want to quickly find all references of something on a given path, you can use:
|
I struggle with the same (the 'Find all references' or peek them with SHIFT+F12) shows only the method itself or the usage in the local file. |
How to disable this feature (it seems I have to enable gopls.)? |
We are currently in the process of adding support for this feature. The language server is designed to be more performant for modules, so turning it off will be fine if you are in @zhangpy: If you can file an issue with a repro case and the information requested here, I would be happy to investigate it. |
Thanks for the reply. I could wait until gopls is ready, thanks. |
This has been complete as of a few weeks ago. Closing. |
good job |
@stamblerre is there a timeline on when this will make its way to the gopls installed from vscode? |
The next |
ok n00b question : what would be a good way to install gopls from master? Update: found it https://github.com/golang/tools/blob/master/gopls/doc/user.md |
To install |
Gave this a very quick go ☝️ - still only finds all references from within the current package - not workspace/project wide with |
@magnetikonline: This should work at master. If it's not working, please file a new issue with a repro case, and we can help investigate. It would also be helpful if you attach the output of the |
Will do @stamblerre - it's more than likely my user error - I did try moving my (largish) non-gomodules test project in/out of GOPATH thinking that might have been the cause. Outside of GOPATH, it didn't work at all - as expected - bit thought it might have been the trigger. Might also try to mock up a really simple project with a few packages to confirm as well. |
|
Yeah I'm pretty sure I'm doing all that. I'll give it a crack over the weekend and raise an issue if no luck. Thanks! |
I installed 6e064ea(contains commit caa0b0f which I think is the relevant one for this issue) and when |
@problame: Can you try reproducing in a real Go project? Our testdata directory is not a good place for repro examples, as the testing framework does extra work to set up the directory structure. You will notice that |
Hello @stamblerre I played with this some more just now!!!:
Sorry if this next bit is confusing! This is what I see with "default"
Then switching to
So... right now if I do a "find all references" from within the sub/child packages it finds everything - but from the root package, no change. Does that make sense? Sorry for adding more noise to this thread - if you like I can port this over to a new issue. Certainly |
It's reproducible in: https://github.com/zrepl/zrepl/blob/problame/resumable-and-encrypted-send-recv/zfs/holds.go#L78 ZFSReleaseAllOlderAndIncludingGUID is used in other packages within the same module (=repo in this case), but those use-sites are not found by Find All References. |
I filed #35936 to continue this discussion. @magnetikonline: The position arguments to @problame: Thanks for that report - we'll take a look (I was able to reproduce). |
Not a problem @stamblerre - if you do have a need for that, let me know. But it seems there is a nice workable case with what @problame has shown, already in a repo. |
Hello @stamblerre I see version I'll outline with some code this time - hope this helps, and sorry for all the fruit package names! // main.go
package main
import (
"fmt"
"magnetik.test/hello/apple"
"magnetik.test/hello/orange"
)
func main() {
fmt.Println("testing")
fmt.Println(apple.WhatColorApple())
fmt.Println(orange.WhatColorOrange())
} // apple/main.go
package apple
func WhatColorApple() string {
return "it's a red apple"
} // orange/main.go
package orange
import (
"magnetik.test/hello/apple"
)
func WhatColorOrange() string {
return "it's an orange orange, but also have... " + apple.WhatColorApple()
}
$ gopls version
golang.org/x/tools/gopls 0.2.2
golang.org/x/tools/[email protected] h1:ujGisyytgY1VGcmd66wIJ9+wVAfmodXj6daHM43HRXk= Hope that helps! |
@magnetikonline: v0.2.2 is a patch release, so it doesn't contain the changes made on master. It only had a few minor bug fixes, so I would not expect any difference of behavior from the previous tagged version. The next version with the changes for find references will be tagged v0.3.0. Still, thank you for the detailed report! |
@stamblerre ugh, my bad! 🤦♂ - thanks for clarifying that! I'll check in once |
@stamblerre, why does not v0.3.0 drop? :) |
It'll be out as soon as we work through the issues here: https://github.com/golang/go/milestone/129. I will post on #33030 when it is released. |
This didn't work for me, it still used the language server. |
@yoesmat that's because the options offered with Only options are to disable language server entirely, or wait for 0.3.0 of |
Thanks @magnetikonline |
Hello @stamblerre - I've eagerly installed $ gopls version
golang.org/x/tools/gopls 0.2.2
golang.org/x/tools/[email protected] h1:ujGisyytgY1VGcmd66wIJ9+wVAfmodXj6daHM43HRXk=
$ GO111MODULE="on" go get golang.org/x/tools/[email protected]
$ gopls version
golang.org/x/tools/gopls v0.3.0
golang.org/x/tools/[email protected] h1:l9KKK1/n6CIbfgaUvHBWAvCfOxcl1N+KSOK79OlPIao= Then from VS Code restart/restart language server. All those "Find all references" actions work exactly as expected. Thanks for being so active on this topic and great work on the |
Glad to hear the update's working well for you, and thanks for following up! |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
In Vscode I used Find All References.
What did you expect to see?
See all usages.
What did you see instead?
I see usages only in the file in which objects are defined.
The text was updated successfully, but these errors were encountered: