mirror of
https://github.com/golang/go
synced 2024-11-11 19:51:37 -07:00
cmd/go: compute BuildInfo and EmbedFiles when listing export data
'go list -export' lists the locations of compiled artifacts, so it needs to load all of the metadata needed to compile each package. Fixes #58885. Change-Id: Ie78527e0fb423698fb4195fe50e0b6925b05aa8c Reviewed-on: https://go-review.googlesource.com/c/go/+/477197 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
parent
f521077b01
commit
6615324f79
@ -609,8 +609,8 @@ func runList(ctx context.Context, cmd *base.Command, args []string) {
|
||||
// might not expect those errors to stop showing up.
|
||||
// See issue #52443.
|
||||
SuppressDeps: !listJsonFields.needAny("Deps", "DepsErrors"),
|
||||
SuppressBuildInfo: !listJsonFields.needAny("Stale", "StaleReason"),
|
||||
SuppressEmbedFiles: !listJsonFields.needAny("EmbedFiles", "TestEmbedFiles", "XTestEmbedFiles"),
|
||||
SuppressBuildInfo: !*listExport && !listJsonFields.needAny("Stale", "StaleReason"),
|
||||
SuppressEmbedFiles: !*listExport && !listJsonFields.needAny("EmbedFiles", "TestEmbedFiles", "XTestEmbedFiles"),
|
||||
}
|
||||
pkgs := load.PackagesAndErrors(ctx, pkgOpts, args)
|
||||
if !*listE {
|
||||
|
17
src/cmd/go/testdata/script/list_export_embed.txt
vendored
Normal file
17
src/cmd/go/testdata/script/list_export_embed.txt
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Regression test for https://go.dev/issue/58885:
|
||||
# 'go list -json=Export' should not fail due to missing go:embed metadata.
|
||||
|
||||
[short] skip 'runs the compiler to produce export data'
|
||||
|
||||
go list -json=Export -export .
|
||||
|
||||
-- go.mod --
|
||||
module example
|
||||
go 1.20
|
||||
-- example.go --
|
||||
package example
|
||||
|
||||
import _ "embed"
|
||||
|
||||
//go:embed example.go
|
||||
var src string
|
Loading…
Reference in New Issue
Block a user