x/tools/go/packages: "files=" queries don't seem to work #58726
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
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
x/tools/go/packages is documented as taking a special
files=
query to ask for a list of packages containing a set of Go source files. In all my tests, file-based queries always return zero packages.Here's a small example program: https://github.com/cespare/misc/blob/main/pkgfilesquery/pkgfilesquery.go
If you want to run this, clone the repo and then, from the repo root, run
What did you expect to see?
What did you see instead?
I tried a variety of things including absolute paths but I always get 0 packages.
If I use a normal Go list pattern like
./columns
orgithub.com/cespare/misc/columns
rather than afile=
query, then it works fine.I traced the inner workings of x/tools/go/packages briefly and it looks like the code initially gets the correct set of packages but no "roots" and then the subsequent "refinement" step filters the package list to zero.
There's also a documentation issue here. The docs say:
But (a) it doesn't indicate how the filenames are resolved (are they relative to the cwd or config.Dir?) and (b) it suggests that
~
might work but I don't see any evidence that~
is implemented in the code./cc @matloob, the owner according to s/owners
The text was updated successfully, but these errors were encountered: