A simple tool to generate a dependency graph of Golang packages. The output has the same format as the go mod graph command. It can be used alongside tools that support that format such as modgraphviz.
- modgraphviz:
$ go install golang.org/x/exp/cmd/modgraphviz - graphviz: https://graphviz.org/download/
$ go install github.com/jybp/gopkgraph@latestList all dependencies of the package in the current directory belonging to the same module:
$ gopkgraph | modgraphviz | dot -Tpng -o pkgs.pngList all dependencies of the package in the current directory including one level of dependencies from other modules belonging to github.com/user:
$ gopkgraph -mods=1 | grep " \github.com/user" | modgraphviz | dot -Tpng -o pkgs.png| Flag | Description |
|---|---|
-pkg |
Path to the package. Omit this flag to target the current directory. (optional) |
-mods |
Max depth for packages from other modules. (optional) |
-stdlib |
Max depth for packages from the stdlib. (optional) |
-trim |
Trim module prefix. (optional) |
-help |
Print flags. (optional) |