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.
go listprovides a.Depswhich has the recursive list of dependencies for.Imports. This is important because it provides the complete list of dependencies that must be fulfilled to rungo buildUnfortunately there is no recursive dependency provided for
TestImportsorXTestImports. Those have a dependency tree that needs to be fulfilled in order togo testbut it's non-trivial to retrieve that dependency list. (especially when trying to filter out stdlib entries)Currently
What's expected?
This would allow a command like the following to output the complete set of dependencies needed to run
go buildorgo test.Currently you have to run
go list '{{join .Deps "\n"}}' $import_pathon each import path from.TestImportsand.XTestImports.