From c75a617af02fcfa53effed30803f2a96388680d5 Mon Sep 17 00:00:00 2001 From: Quan Tong Date: Thu, 19 Oct 2023 11:44:32 +0700 Subject: [PATCH] cmd/go/internal/work: set Incomplete to true if there is an error Fixes #57724 Change-Id: I3d419985ff41d5ee93bb56d8c7ca5cd1d7231920 Reviewed-on: https://go-review.googlesource.com/c/go/+/536418 Auto-Submit: Bryan Mills Reviewed-by: Bryan Mills TryBot-Result: Gopher Robot Run-TryBot: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov --- src/cmd/go/internal/work/exec.go | 1 + src/cmd/go/testdata/script/list_export_e.txt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 4f4fb704b8b..ecad3248866 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -164,6 +164,7 @@ func (b *Builder) Do(ctx context.Context, root *Action) { if b.AllowErrors && a.Package != nil { if a.Package.Error == nil { a.Package.Error = &load.PackageError{Err: err} + a.Package.Incomplete = true } } else { var ipe load.ImportPathError diff --git a/src/cmd/go/testdata/script/list_export_e.txt b/src/cmd/go/testdata/script/list_export_e.txt index 8e4c361fc4e..6d5dd39f0bd 100644 --- a/src/cmd/go/testdata/script/list_export_e.txt +++ b/src/cmd/go/testdata/script/list_export_e.txt @@ -6,6 +6,10 @@ go list -f '{{with .Error}}{{.}}{{end}}' -e -export ./... ! stderr '.' stdout '^# example.com/p2\np2'${/}'main\.go:7:.*' +go list -export -e -f '{{.ImportPath}} -- {{.Incomplete}} -- {{.Error}}' ./... +stdout 'example.com/p1 -- false -- ' +stdout 'example.com/p2 -- true -- # example.com/p2' + go list -e -export -json=Error ./... stdout '"Err": "# example.com/p2'