Short of building a dependency graph, is there an existing way to retrieve a list of dependent packages given a target package?
Sourcegraph has a badge (shield) that shows you how many packages use a specific package but when I click their link to go to their UI, I cannot find a count or list of packages. Here's more info:
Example badge:
GitHub has a dependency graph but it doesn't appear to list packages for Go and its docs only mention JavaScript and Ruby per the following:
go list
can do this for you, with use of the -f
flag.
go list -f '{{.Imports}}' ./...
Will show a list of all imports for the current and child directories. You can pipe this through sort -u
, for example, to get a list of all dependencies, or do other standard shell-based massaging. Consult the documentation for all of the formatting options available.
If you need a recursive list, this is also possible with some shell scripting, by then using doing the same thing recursively on the output of the above command.