Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go list -json missing TestEmbedFiles #61183

Open
yz89122 opened this issue Jul 5, 2023 · 3 comments
Open

cmd/go: go list -json missing TestEmbedFiles #61183

yz89122 opened this issue Jul 5, 2023 · 3 comments
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Unfortunate
Milestone

Comments

@yz89122
Copy link

yz89122 commented Jul 5, 2023

What version of Go are you using (go version)?

$ go version
go version go1.20.5 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/aaa/Library/Caches/go-build"
GOENV="/Users/aaa/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/aaa/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/aaa/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.20.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.20.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.20.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pl/aaa/T/go-build111=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Clone https://github.com/yz89122/go-list-test-embed-error
  2. Run go list -json .
  3. See the output

What did you expect to see?

Expect field .TestEmbedFiles presented.

What did you see instead?

Field .TestEmbedFiles is missing.

@yz89122 yz89122 changed the title affected/package: Command go list is missing field .TestEmbedFiles Command go list: missing field .TestEmbedFiles Jul 5, 2023
@yz89122 yz89122 changed the title Command go list: missing field .TestEmbedFiles Command go list -json: missing field .TestEmbedFiles Jul 5, 2023
@bcmills bcmills added GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jul 5, 2023
@bcmills bcmills added this to the Backlog milestone Jul 5, 2023
@bcmills
Copy link
Contributor

bcmills commented Jul 5, 2023

Hmm. We don't normally need to resolve embed patterns for test sources unless we are actually building the test (which would correspond to the -test flag in go list).

Probably we should do the extra work to resolve them in go list when the fields may be needed (compare #29666).

@bcmills bcmills changed the title Command go list -json: missing field .TestEmbedFiles cmd/go: go list -json missing TestEmbedFiles Jul 5, 2023
@yz89122
Copy link
Author

yz89122 commented Jul 6, 2023

Sorry, I didn't realize the field will only presented when the -test flag is given.

Thanks.

@yz89122 yz89122 closed this as completed Jul 6, 2023
@bcmills bcmills reopened this Jul 11, 2023
@bcmills
Copy link
Contributor

bcmills commented Jul 11, 2023

Discussed with @rsc. Our thinking is:

  1. Errors in resolving TestEmbedFiles shouldn't cause go list to fail for the non-test package.

  2. On the other hand, the -test flag probably shouldn't be needed to populate the fields. (-json, or -f with a template that refers to TestEmbedFiles, should probably suffice.)

But on further consideration, those two points seem to be at odds with each other. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Unfortunate
Projects
None yet
Development

No branches or pull requests

2 participants