This is a module dependency visualizer for go mod. It is forked from https://github.com/poloxue/modv, and added some module or package filter function.
Modv's usage is different in different systems.
Install graphviz
. For Ubuntu/Debian
$ sudo apt-get install graphviz
For ArchLinux
$ sudo pacman -S --needed graphviz
Install modv
and use it.
$ go install github.com/DoomConquer/modv
- the whole module dependency visualizer.
$ go mod graph | modv | dot -T svg -o /tmp/modv.svg && xdg-open /tmp/modv.svg
- filter part of module dependency visualizer.
$ go mod graph | modv moduleName@version | dot -T svg -o /tmp/modv.svg && xdg-open /tmp/modv.svg
or
$ go mod graph | modv -f moduleName@version | dot -T svg -o /tmp/modv.svg && xdg-open /tmp/modv.svg
- color part of module dependency visualizer.
$ go mod graph | modv -c moduleName@version | dot -T svg -o /tmp/modv.svg && xdg-open /tmp/modv.svg
$ brew install graphviz
$ go get github.com/DoomConquer/modv
Try the following.
cd goProject
$ go mod graph | modv | dot -T png | open -f -a /Applications/Preview.app
If error accured, for eaxmple,FSPathMakeRef(/Applications/Preview.app) failed with error -43.
,try the command:
- the whole module dependency visualizer.
$ go mod graph | modv | dot -T png | open -f -a /System/Applications/Preview.app
- filter part of module dependency visualizer.
$ go mod graph | modv moduleName@version | dot -T png | open -f -a /System/Applications/Preview.app
or
$ go mod graph | modv -f moduleName@version | dot -T png | open -f -a /System/Applications/Preview.app
- color part of module dependency visualizer.
$ go mod graph | modv -c moduleName@version | dot -T png | open -f -a /System/Applications/Preview.app
First, install graphviz
:
$ choco install graphviz.portable
For MSYS2
$ pacman -S mingw-w64-x86_64-graphviz
Try it.
$ go get github.com/DoomConquer/modv
- the whole module dependency visualizer.
$ go mod graph | modv | dot -T svg -o graph.svg; start graph.svg
- filter part of module dependency visualizer.
$ go mod graph | modv moduleName@version | dot -T svg -o graph.svg; start graph.svg
or
$ go mod graph | modv -f moduleName@version | dot -T svg -o graph.svg; start graph.svg
- color part of module dependency visualizer.
$ go mod graph | modv -c moduleName@version | dot -T svg -o graph.svg; start graph.svg
If MacOS, tye the following:
$ git clone https://github.com/poloxue/testmod
$ cd testmod
- the whole module dependency visualizer.
$ go mod graph | modv | dot -T png | open -f -a /System/Applications/Preview.app
Output:
- filter part of module dependency visualizer.
go mod graph | modv rsc.io/quote/v3@v3.1.0 | dot -T png | open -f -a /System/Applications/Preview.app
or
go mod graph | modv -f rsc.io/quote/v3@v3.1.0 | dot -T png | open -f -a /System/Applications/Preview.app
Output:
- color part of module dependency visualizer.
$ go mod graph | modv -c rsc.io/quote/v3@v3.1.0 | dot -T png | open -f -a /System/Applications/Preview.app
Output: