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: reference / hover info / definition not found from test package #48466

Closed
leitzler opened this issue Sep 19, 2021 · 1 comment
Closed
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@leitzler
Copy link
Contributor

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

$ go version
go version devel go1.18-14e812bfc Fri Sep 17 00:31:49 2021 +0000 darwin/amd64
$ go list -m golang.org/x/tools golang.org/x/tools/gopls
golang.org/x/tools v0.1.6-0.20210902182115-3b801c8b8389
golang.org/x/tools/gopls v0.0.0-20210902182115-3b801c8b8389

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
N/A

What did you do?

With the file structure below I opened up foo_test.go, move cursor to bar.Bar and tried to go to definition / hover / find references.

-- bar/bar.go --
package bar

import "foo"

const Bar = "bar"

const X = foo.Foo(false)
-- foo.go --
package foo

type Foo bool
-- foo_test.go --
package foo_test

import (
	"foo/bar"
	"testing"
)

func TestFoo(t *testing.T) {
	_ = bar.Bar // <= Hover / Go to def / Find refs / etc. from "Bar" here
}
-- go.mod --
module foo

go 1.18
-- other_test.go --
package foo

What did you expect to see?

Results from any of the requests.

What did you see instead?

No results.

It seems like the existence of other_test.go is the key here (i.e. both a _test.go file and package foo_test), if it isn't present everything works as expected.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Sep 19, 2021
@gopherbot gopherbot added this to the Unreleased milestone Sep 19, 2021
@leitzler
Copy link
Contributor Author

I took a look in the source and noticed that this was already fixed by CL 347563, apologies for the noise.

@golang golang locked and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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

2 participants