A Go dependency graph visualization tool
godepgraph is a program for generating a dependency graph of Go packages.
go install github.com/kisielk/godepgraph@latestFor basic usage, just give the package path of interest as the first argument:
godepgraph github.com/kisielk/godepgraphIf you intend to graph a go mod project, your package should be passed as a relative path:
godepgraph ./pkg/apiThe default output is a graph in Graphviz dot format. If you have the graphviz tools installed you can render it by piping the output to dot:
godepgraph github.com/kisielk/godepgraph | dot -Tpng -o godepgraph.pngYou can also generate Mermaid graphs:
godepgraph -format mermaid github.com/kisielk/godepgraph > graph.mmdBy default godepgraph will display packages in the standard library in the graph, though it will not delve in to their dependencies.
godepgraph uses a simple color scheme to denote different types of packages:
$GOROOT.$GOPATH.$GOPATH.$GOPATH that uses cgo by importing the special package "C".If you want to ignore standard library packages entirely, use the -s flag:
godepgraph -s github.com/kisielk/godepgraphIf you want to ignore vendored packages entirely, use the -novendor flag:
godepgraph -novendor github.com/something/elseImport paths can be ignored in a comma-separated list passed to the -i flag:
godepgraph -i github.com/foo/bar,github.com/baz/blah github.com/something/elseThe packages and their imports will be excluded from the graph, unless the imports are also imported by another package which is not excluded.
Import paths can also be ignored by prefix. The -p flag takes a comma-separated list of prefixes:
godepgraph -p github.com,launchpad.net bitbucket.org/foo/barHere's some example output for godepgraph itself:
Using godepgraph -format mermaid github.com/kisielk/godepgraph:
…Using godepgraph -format graphviz github.com/kisielk/godepgraph:
Here's the output of godepgraph -format mermaid -nostdlib github.com/kisielk/errcheck:
…No open issues yet, or sync has not completed.