From: Michael Matloob Date: Sat, 16 Jan 2021 00:18:34 +0000 (-0500) Subject: cmd/go: set Incomplete field on go list output if no files match embed X-Git-Tag: go1.16rc1~56 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=803d18fc6c656c5410a62157de0328a669e1b56b;p=gostls13.git cmd/go: set Incomplete field on go list output if no files match embed If no files match the embed pattern, the Error field will be set on the package output by go list. Also set the Incomplete field for consistency. Fixes #43727 Change-Id: I5b4bb2a03a751269641a9bc4ef1d0fa0e37d46aa Reviewed-on: https://go-review.googlesource.com/c/go/+/284257 Trust: Michael Matloob Run-TryBot: Michael Matloob TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 92dd794871..3f67927111 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -1809,6 +1809,7 @@ func (p *Package) load(ctx context.Context, path string, stk *ImportStack, impor p.EmbedFiles, p.Internal.Embed, err = resolveEmbed(p.Dir, p.EmbedPatterns) if err != nil { + p.Incomplete = true setError(err) embedErr := err.(*EmbedError) p.Error.setPos(p.Internal.Build.EmbedPatternPos[embedErr.Pattern]) diff --git a/src/cmd/go/testdata/script/embed.txt b/src/cmd/go/testdata/script/embed.txt index 2ad799b7a7..6ad42e9cd1 100644 --- a/src/cmd/go/testdata/script/embed.txt +++ b/src/cmd/go/testdata/script/embed.txt @@ -46,6 +46,8 @@ stderr '^x.go:5:12: pattern [*]t: cannot embed directory t: contains no embeddab cp x.txt t/.git ! go build -x stderr '^x.go:5:12: pattern [*]t: cannot embed directory t: contains no embeddable files$' +go list -e -f '{{.Incomplete}}' +stdout 'true' [symlink] symlink t/x.link -> ../x.txt [symlink] ! go build -x [symlink] stderr '^x.go:5:12: pattern [*]t: cannot embed directory t: contains no embeddable files$'