bazel-gazelle icon indicating copy to clipboard operation
bazel-gazelle copied to clipboard

'invalid use of internal package' in IDE in external tests

Open scaiper opened this issue 10 months ago • 4 comments

What version of gazelle are you using?

v0.36.0

What version of rules_go are you using?

v0.46.0

What version of Bazel are you using?

7.1.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Linux amd64

What did you do?

Created external go test inside some internal package. Run gazelle. Open IDE using gopls with gopackagesdriver from rules_go.

What did you expect to see?

Code navigation should work as usual.

What did you see instead?

An "invalid use of internal package" errors in imports.

This happens due to incorrect PkgPath in gopackagesdriver output. Gazelle do not specify importpath for go_test targets, as a result gopackagesdriver in rules_go is unable to infer correct importpath. While correct importpath is not needed to build or test go_test targets, I do not know how to fix this issue without specifying it.

Maybe relevant https://github.com/bazelbuild/rules_go/issues/3845

scaiper avatar Apr 09 '24 16:04 scaiper