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

x/tools/go/packages: go list emits no CompiledGoFiles for packages that depend on one with an error #28755

alandonovan opened this issue Nov 13, 2018 · 0 comments


Copy link

@alandonovan alandonovan commented Nov 13, 2018

The TestLoadSyntaxError test case establishes an import graph a->b->c->d->e->f where e contains an error:

$ head $(find src -name \*.go)
==> src/ <==
package d; import ""; const D = "d" + e.E
==> src/ <==
package c; import ""; const C = "c" + d.D
==> src/ <==
package f; const F = "f"
==> src/ <==
package e; import ""; const E = "e" + f.F + 1
==> src/ <==
package b; import ""; const B = "b" + c.C
==> src/ <==
package a; import ""; const A = "a" + b.B

If you run tip go list on a and c (as in the test), the reported set of CompiledGoFiles is accurate only for e and f, but not for any package above them, presumably because no build was attempted for those packages:

$ go list -compiled -f '{{.ImportPath}} {{.GoFiles}} {{.CompiledGoFiles}}' -deps -export 
src/ cannot convert "ef" (type untyped string) to type int
src/ invalid operation: "ef" + 1 (mismatched types string and int) [f.go] [f.go] [e.go] [e.go] [d.go] [] [c.go] [] [b.go] [] [a.go] []

Eliminating the type error cause go list to report CompiledGoFiles all the way up:

$ GOPATH=$(pwd) go list -compiled -f '{{.ImportPath}} {{.GoFiles}} {{.CompiledGoFiles}}' -deps -export [f.go] [f.go] [e.go] [e.go] [d.go] [d.go] [c.go] [c.go] [b.go] [b.go] [a.go] [a.go]

This is arguably a bug in go list, but it suggests we need better test coverage and a more complex and better documented workaround for missing CompiledGoFiles than go/packages has today.

@gopherbot gopherbot added this to the Unreleased milestone Nov 13, 2018
@alandonovan alandonovan changed the title x/tools/go/packages: subtle bugs related to CompiledGoFiles x/tools/go/packages: go list emits no CompiledGoFiles for packages that depend on one with an error Nov 13, 2018
@gopherbot gopherbot added the Tools label Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.