There could be an issue with rich dependency tree in some Go project. So it's worth having some tools to analyze them.
Two different tools are described here, they could be installed with make tools
command.
Project is here. Let's analyze mainservice, run:
$ git clone [email protected]:godepsresolve/mainservice.git
$ cd mainservice
$ gomod graph -a '**' | dot -Tsvg -o graph.svg
Then open graph.svg with your favorite image viewer.
You can also run gomod only for your dependencies, because in large projects with many dependencies graph becomes unreadable:
$ gomod graph -a 'github.com/godepsresolve/**' | dot -Tsvg -o graph.svg
.
Project is here. Let's analyze mainservice, run:
$ git clone [email protected]:godepsresolve/mainservice.git
$ cd mainservice
$ go mod graph | modgraphviz | dot -Tsvg -o graph_modg.svg
Then open graph.svg with your favorite image viewer.
As for only required group of dependency you can grep them before processing (space before github.com is not a typo):
go mod graph | grep ' github.com' | modgraphviz | dot -Tsvg -o graph_modg.svg
.
Let's analyze mainservice_replace_fork, run:
$ git clone [email protected]:godepsresolve/mainservice_replace_fork.git
$ cd mainservice_replace_fork
$ gomod graph -a '**' | dot -Tsvg -o graph.svg
Then open graph.svg with your favorite image viewer.
Let's analyze mainservice_replace_fork, run:
$ git clone [email protected]:godepsresolve/mainservice_replace_fork.git
$ cd mainservice_replace_fork
$ go mod graph | modgraphviz | dot -Tsvg -o graph_modg.svg
Then open graph.svg with your favorite image viewer.
As you can see modgrapviz method is useless here, because go mod graph
does not consider replace directive. So I cannot recommend go mod graph
with modgraphviz in case with replace.