-
Notifications
You must be signed in to change notification settings - Fork 760
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
gopls: gopls does not find all reference in the workspace #2443
Comments
FWIW, this is not what I observe, and is certainly not the intended behavior. Gopls should find all references within any workspace packages. In other words, if opening up a module root, gopls should find all references contained in any package inside the module. (golang/go#43144 catalogs a known bug about references in test variants, but that doesn't seem to be what is reported here). It may be that somehow gopls is failing to compute workspace packages correctly. A more specific reproducer would be helpful. |
|
No, find all references should consider all workspace packages. If you do not see this happening, it is either a bug or a misconfiguration (or both). If you had a small reproducer, or could share LSP logs, it would help us understand what is going on in your session. |
I don't really have a minimal reproducer, but I do have a workspace error, could that be related? Also, where do I find LSP logs, where are they located? |
Yes, that is almost certainly related. What is your workspace error? Instructions for how to collect logs are here: |
Just created another playground using go module and the find all references seem to work as expected, but my actual working repo is still not working |
if a function in package A has been referenced in both package B and C, if I open a file where it referenced this function in package B, then |
This error is surprising: Do you have a module path named "github.com" in your workspace? |
Yes, we're using module mod, this is some package inside our module, I can confirm 'Find all reference' only works after I open certain packages, I deliberately leave only one file open and when the packages are loaded(except for this workspace error), find all reference only finds itself, but after I open other packages where this function is referenced, those references are found as well. |
Sorry, I don't understand. Do you have a |
I do, there is a go.mod file, it's in the root directory of this repo. |
Gopls is having trouble loading your workspace. Does Are you able to share the full logs from a gopls session? |
It seems so, |
this happens for me also.
testgo.code-workspace:
moda/go.mod module github.com/test/moda
go 1.19 moda/a.go package moda
import "fmt"
func TestFunc1() {
fmt.Println("test")
} modb/go.mod module github.com/test/modb
go 1.19
replace github.com/test/moda => ../moda/
require github.com/test/moda v0.0.0-00010101000000-000000000000 modb/main.go package main
import "github.com/test/moda"
func main() {
moda.TestFunc1()
} when doing "Find All References" in |
have the same issue here. is there any workaround? |
Try the following commands from your workspace directory: go work init
go work use . This worked for me. |
What version of Go, VS Code & VS Code Go extension are you using?
go version go1.13.15 linux/amd64
vscode:
Version: 1.70.2 (Universal)
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.Go: Locate Configured Go Tools
command.Share the Go related settings you have added/edited
see below
Run
Preferences: Open Settings (JSON)
command to open your settings.json file.Share all the settings with the
go.
or["go"]
orgopls
prefixes.Describe the bug
Bug description:
Gopls only finds the references on package level, not on module level.
References in other packages can be found/peeked ONLY AFTER I opened certain package and see the reference,
which is useless, because the point of finding all references is it finds all references for me without needing to open
all the packages.
What I expect:
Find all reference finds all references of a function on a module level, it should search all the packages in this module.
Steps to reproduce the behavior:
Use
Find all references
allPeek references
feature on any function in a Go project using go module mode, this happens.Screenshots or recordings
N/A
The text was updated successfully, but these errors were encountered: