-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Open
Labels
Milestone
Description
go list
provides a .Deps
which has the recursive list of dependencies for .Imports
. This is important because it provides the complete list of dependencies that must be fulfilled to run go build
Unfortunately there is no recursive dependency provided for TestImports
or XTestImports
. Those have a dependency tree that needs to be fulfilled in order to go test
but it's non-trivial to retrieve that dependency list. (especially when trying to filter out stdlib entries)
Currently
// Dependency information
Imports []string // import paths used by this package
Deps []string // all (recursively) imported dependencies
TestImports []string // imports from TestGoFiles
XTestImports []string // imports from XTestGoFiles
What's expected?
// Dependency information
Imports []string // import paths used by this package
Deps []string // all (recursively) imported dependencies
TestImports []string // imports from TestGoFiles
TestDeps []string // all (recursively) imported dependencies from TestGoFiles
XTestImports []string // imports from XTestGoFiles
XTestDeps []string // all (recursively) imported dependencies from XTestGoFiles
This would allow a command like the following to output the complete set of dependencies needed to run go build
or go test
.
go list -f '{{join .Deps "\n"}}{{if len .TestDeps}}{{"\n"}}{{end}}{{join .TestDeps "\n"}}{{if len .XTestDeps}}{{"\n"}}{{end}}{{join .XTestDeps "\n"}}' | sort | uniq
Currently you have to run go list '{{join .Deps "\n"}}' $import_path
on each import path from .TestImports
and .XTestImports
.
stapelberg, AlekSi, yliu-wasabi and lhinderberger