1
0
mirror of https://github.com/golang/go synced 2024-11-22 20:04:47 -07:00

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 <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
Michael Matloob 2021-01-15 19:18:34 -05:00
parent 6e243ce71d
commit 803d18fc6c
2 changed files with 3 additions and 0 deletions

View File

@ -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) p.EmbedFiles, p.Internal.Embed, err = resolveEmbed(p.Dir, p.EmbedPatterns)
if err != nil { if err != nil {
p.Incomplete = true
setError(err) setError(err)
embedErr := err.(*EmbedError) embedErr := err.(*EmbedError)
p.Error.setPos(p.Internal.Build.EmbedPatternPos[embedErr.Pattern]) p.Error.setPos(p.Internal.Build.EmbedPatternPos[embedErr.Pattern])

View File

@ -46,6 +46,8 @@ stderr '^x.go:5:12: pattern [*]t: cannot embed directory t: contains no embeddab
cp x.txt t/.git cp x.txt t/.git
! go build -x ! go build -x
stderr '^x.go:5:12: pattern [*]t: cannot embed directory t: contains no embeddable files$' 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] symlink t/x.link -> ../x.txt
[symlink] ! go build -x [symlink] ! go build -x
[symlink] stderr '^x.go:5:12: pattern [*]t: cannot embed directory t: contains no embeddable files$' [symlink] stderr '^x.go:5:12: pattern [*]t: cannot embed directory t: contains no embeddable files$'