x/tools/go/packages: Load in NeedName|NeedFiles mode can produce incorrect results for certain modules #31894
Labels
FrozenDueToAge
modules
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
This issue is related to #29452, #31087, and #31893, but is more narrowly focused on the correctness of the
packages.NeedName | packages.NeedFiles
mode.Background
Both
go/packages
andgo/build
are concerned with loading Go packages and returning information about them.Go packages may be inside modules that are tidy and compile successfully, or they may be incomplete and fail to build in certain configurations. Loading information about a package should succeed independently from whether or not building said package (in a specific configuration) can be done without build errors.
Environment
Issue
Incorrect results are produced when using the
go/packages
package inpackages.NeedName | packages.NeedFiles
mode. Correct results are produced by thego/build
package.To reproduce the issue, create a target package to be imported in a temporary directory
/tmp/target
with the following files:Then, inside another directory, create the following test command:
Run it as follows:
Notice that
go/build
produced correct results, whilego/packages
produced incorrect results (an error)./cc @matloob per owners.
The text was updated successfully, but these errors were encountered: