Closed waltercacau closed 1 month ago
I believe I have a working fix w/ tests in https://github.com/bazelbuild/rules_go/pull/4002 . Please take a look when you have a chance.
CCing as I saw them reviewing PRs in the affected code @fmeum @JamyDev . Please forward to other folks if I got this wrong :)
What version of rules_go are you using?
Reproduced this on master of https://github.com/bazelbuild/rules_go which as of the time of this writing was at this commit: https://github.com/bazelbuild/rules_go/commit/86a7f025d2fc052ab6154603b481cb7e4419598f
What version of gazelle are you using?
0.34.0
What version of Bazel are you using?
7.2.1
Does this issue reproduce with the latest releases of all the above?
N/A, found this on master of rules_go
What operating system and processor architecture are you using?
Mac OS
Any other potentially useful information about your toolchain?
N/A
What did you do?
This was discovered while I was trying to setup rules_go gopackagedriver with VSCode IDE for a project I work on. In our usecase we work on a big monorepo and projects are subdirectories of that monorepo. The workspace structure looks like this:
The script I setup in vscode looked like this:
When working on one of the projects, let's say project1, we setup VSCode to only open project1 folder (and therefore the script above would run with working directory being project1. While working on it, gopackagedriver had to respond to the following queries:
I expected the first query involving
./...
to only return results from project1, but instead it returned stuff for @//:stdlib. Playing with it I also noticed that it did not work as expected for other relative queries like file=./main.go . While my VSCode setup does not send those queries I would have expected them to work and may impact people working on other tools/IDEs.I was able to reproduce this within https://github.com/bazelbuild/rules_go itself. First to setup:
Then ran the following test cases: A)
(cd go/tools/gopackagesdriver; echo {} | bazel run //go/tools/gopackagesdriver -- ./...)
B)(cd go/tools/gopackagesdriver; echo {} | bazel run //go/tools/gopackagesdriver -- file=main.go)
What did you expect to see?
A) Should return results based on packages in //go/tools/gopackagesdriver/... (which only has //go/tools/gopackagesdriver:gopackagesdriver_lib) B) Should return results based on the package that contains go/tools/gopackagesdriver/main.go (which is //go/tools/gopackagesdriver:gopackagesdriver_lib)
What did you see instead?
A) targets based on
kind("^(go_library) rule$", ...)]
which is all go_library in the repository rather the ones in the subdirectory go/tools/gopackagesdriverB) Targets based on the
kind("^(go_library|go_test|go_binary) rule$", same_pkg_direct_rdeps("main.go"))
query and an error.