Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/cmd/guru: confusing behavior on source files whose package can't be located #17516
CL 30451 caused guru to silently treat a file that it can't locate beneath $GOPATH as if it belonged to an anonymous package (actually, one named "command-line-arguments") containing just that file. The behavior is convenient for some queries since it allows you to, for instance, describe arbitrary identifiers in any Go source file. However, for "reverse" queries such as "implements", its benefits are more dubious. Although it may cause "implements" facts within that single file to be reported, guru will fail to report "implements" facts about packages that import this one, since without knowing the true name of the query package, it cannot enumerate the packages that import it.
The tool should at least issue a warning* when it does this kind of guesswork, and should perhaps not do it at all for queries that use the import graph.
*though warnings are tricky because they may interfere with structured JSON output for editors that merge subcommands' stdout and stderr.