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: support module-local references #32869

Open
anjmao opened this issue Jul 1, 2019 · 10 comments

Comments

@anjmao
Copy link

@anjmao anjmao commented Jul 1, 2019

What version of Go are you using (go version)?

[Info  - 3:24:12 PM] Build info
----------
golang.org/x/tools/cmd/gopls v0.1.1-cmd.gopls
    golang.org/x/tools@(devel)
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=

Go info
-------
go version go1.12.6 darwin/amd64

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/anjmao/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/anjmao/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/anjmao/s/hugo/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/jc/q8b4yjwd5dvgc42xpg6yvm8c0000gn/T/go-build904784213=/tmp/go-build -gno-record-gcc-switches -fno-common"

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.

@gopherbot gopherbot added this to the Unreleased milestone Jul 1, 2019
@gopherbot gopherbot added the gopls label Jul 1, 2019
@suzmue

This comment has been minimized.

Copy link
Contributor

@suzmue suzmue commented Jul 1, 2019

Could you provide more information about this issue? Does this happen with all identifiers or only certain ones?

@suzmue

This comment has been minimized.

Copy link
Contributor

@suzmue suzmue commented Jul 1, 2019

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.

@anjmao

This comment has been minimized.

Copy link
Author

@anjmao anjmao commented Jul 2, 2019

@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.

@arthurkiller

This comment has been minimized.

Copy link

@arthurkiller arthurkiller commented Jul 2, 2019

same as me

@suzmue suzmue changed the title x/tools/cmd/gopls: find all references works only in a single file x/tools/cmd/gopls: find all references works only in a single package Jul 2, 2019
@stamblerre stamblerre changed the title x/tools/cmd/gopls: find all references works only in a single package x/tools/gopls: find all references works only in a single package Jul 2, 2019
@jadekler

This comment has been minimized.

Copy link
Contributor

@jadekler jadekler commented Jul 22, 2019

Also seeing this (see: microsoft/vscode-go#2665)

@stamblerre stamblerre changed the title x/tools/gopls: find all references works only in a single package x/tools/gopls: support module-local references Aug 5, 2019
@stamblerre stamblerre modified the milestones: Unreleased, gopls v1.0 Aug 26, 2019
@gopherbot gopherbot added the Tools label Sep 12, 2019
@henvic

This comment has been minimized.

Copy link

@henvic henvic commented Sep 27, 2019

I just learned that [outside gopls], if you want to quickly find all references of something on a given path, you can use:

go list -f '{{$pkg := .}}{{range .Deps}}{{if eq . "encoding/json"}}{{$pkg.ImportPath}}{{end}}{{end}}' ./...
@ochaloup

This comment has been minimized.

Copy link

@ochaloup ochaloup commented Sep 28, 2019

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.
On another issue, I found that switching off the golang language server may help, see microsoft/vscode-go#1473 (comment)
By disabling this in the golang extension the references are searched over all files in my workspace.
Still, I'm not sure what other features I'm loosing by disabling the language server.

@zhangpy

This comment has been minimized.

Copy link

@zhangpy zhangpy commented Nov 9, 2019

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.
On another issue, I found that switching off the golang language server may help, see microsoft/vscode-go#1473 (comment)
By disabling this in the golang extension the references are searched over all files in my workspace.
Still, I'm not sure what other features I'm loosing by disabling the language server.

How to disable this feature (it seems I have to enable gopls.)?
(My vscode looks like a mess since enable module. - gopls is not ready for this change, unbelievable!)

@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Nov 9, 2019

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 GOPATH mode, but it may result in degraded performance if you are using modules.

@zhangpy: If you can file an issue with a repro case and the information requested here, I would be happy to investigate it.

@zhangpy

This comment has been minimized.

Copy link

@zhangpy zhangpy commented Nov 13, 2019

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 GOPATH mode, but it may result in degraded performance if you are using modules.

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.