A utility to generate a Graphviz dot graph for a golang package structures and functions.
Example:
You need the following installed and in your path:
Please use resent version of dot/graphviz.
#install dot
brew install graphviz
# Install golang
asdf install golang $(cat .tool-versions | grep "golang" | cut -d" " -f2)
git clone [email protected]:pehrs/go2dot.git
cd ./go2dot
make
export PATH=/path/to/go2dot/bin:$PATH# Generate DOT file for a package (including private functions and structs)
go2dot dot --private ./pkg/golang/ > samples/graph.dot
# Generate PNG
dot -Tpng samples/graph.dot -o samples/test-pkg-golang.png# Generate high quality PNG with custom fonts
go2dot graph -Tpng -p ./pkg/golang/ samples/test-pkg-golang.png \
-x '-Gfontname="Ubuntu Mono" -Nfontname="Ubuntu Mono" -Gsize=4,3 -Gdpi=1000'-
We have not tested go expressions to the full yet. The ./samples/sample.go file is used to represent a "typical" golang source for functional testing.
-
dotdoes not generate SVG very well.
Initial release