Repository navigation
go/packages: report go list error in export mode if it lists nothing - #720
CheckPickerUpper wants to merge 2 commits into
Conversation
In a mode that uses export data (NeedExportFile, or NeedTypes without NeedDeps), invokeGo ignores a non-zero exit status from go list, because a failed build still lists the packages, with the errors on stderr and the Export field blank. That reasoning does not hold when go list fails before listing any package, for example because go.mod needs updating: stdout is empty, so Load returns no packages and a nil error, and the cause on stderr is lost. The same load with NeedDeps returns the go list error. In export mode, return the go list error when stdout is empty. A build failure still lists packages, so it keeps the existing behavior. Queries that name .go files are unchanged. TestExportDataModeReportsGoListFailure loads, with NeedName and NeedTypes, a module whose go.mod needs updating. It fails before this change and passes after. TestLoadSyntaxError, which loads packages with a type error in export mode, still passes.
|
This PR (HEAD: 6909201) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/865561. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be Please don’t reply on this GitHub thread. Visit golang.org/cl/865561. |
|
Message from Alan Donovan: Patch Set 1: Code-Review+2 Commit-Queue+1 (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/865561. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2026-11-19T13:51:04Z","revision":"1a9a7f223c7a5ada20c581c361fd4158158806de"} Please don’t reply on this GitHub thread. Visit golang.org/cl/865561. |
|
Message from Alan Donovan: Patch Set 1: -Commit-Queue (Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_57259>) Please don’t reply on this GitHub thread. Visit golang.org/cl/865561. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/865561. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/865561. |
The export-mode comment said a failed build still "lists the packages", which can be read as a listing of names or error messages. Say that it lists the JSON for each package. Co-authored-by: CheckPickerUpper <CheckPickerUpper@users.noreply.github.com>
In a mode that uses export data (NeedExportFile, or NeedTypes
without NeedDeps), invokeGo ignores a non-zero exit status from
go list, because a failed build still lists the packages, with
the errors on stderr and the Export field blank. That reasoning
does not hold when go list fails before listing any package, for
example because go.mod needs updating: stdout is empty, so Load
returns no packages and a nil error, and the cause on stderr is
lost. The same load with NeedDeps returns the go list error.
In export mode, return the go list error when stdout is empty.
A build failure still lists packages, so it keeps the existing
behavior. Queries that name .go files are unchanged.
TestExportDataModeReportsGoListFailure loads, with NeedName and
NeedTypes, a module whose go.mod needs updating. It fails before
this change and passes after. TestLoadSyntaxError, which loads
packages with a type error in export mode, still passes.
Fixes golang/go#83189