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/cmd/guru: 'definition' cannot show declaration of a local object from a different go file #35842

Open
zhouhua015 opened this issue Nov 26, 2019 · 0 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@zhouhua015
Copy link

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

$ go version
go version go1.13.4 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="~/.cache/go-build"
GOENV="~/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="~/Golang"
GOPRIVATE=""
GOROOT="/snap/go/4762"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/snap/go/4762/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="~/Sources/guru-test/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build198801993=/tmp/go-build -gno-record-gcc-switches"

What did you do?

The following is my testing package

files:

- a.go
- bar.go
- foo
  - b.go
- go.mod

go.mod

module example.com/guru/test

go 1.13

a.go

package guru_test

type FooA struct {
}

bar.go

package guru_test

import "example.com/guru/test/foo"

type FooC struct {
}

func bar() {
        var x FooA
        var y foo.FooB
        var z FooC
}

foo/b.go

package foo

type FooB struct {
}

Try to show declaration of selected identifier for FooA:

~/Sources/guru-test$ guru definition bar.go:#99               
guru: no object for identifier

Try to show declaration of selected identifier for FooB:

~/Sources/guru-test$ guru definition bar.go:#115
~/Sources/guru-test/foo/b.go:3:6: defined here as type example.com/guru/test/foo.FooB

Try to show declaration of selected identifier for FooC:

~/Sources/guru-test$ guru definition bar.go:#127
~/Sources/guru-test/bar.go:5:6: defined here as type FooC

What did you expect to see?

Show declaration FooA should give:

~/Sources/guru-test$ guru definition bar.go:#99    
~/Sources/guru-test/a.go:3:6: defined here as type FooA

What did you see instead?

~/Sources/guru-test$ guru definition bar.go:#99               
guru: no object for identifier
@gopherbot gopherbot added this to the Unreleased milestone Nov 26, 2019
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Nov 26, 2019
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants