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
Родитель 6e243ce71d
Коммит 803d18fc6c
2 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -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])

2
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$'