go-callvis is a development tool to help visualize call graph of your Go program using Graphviz's dot format.
Intended purpose of this tool is to provide a visual overview of your program's source code by using call graph and type relations. This is especially useful in larger projects where the complexity of the structure rises.
- focus specific package in program
- limit to include only packages containing prefix
- ignore multiple packages containing prefix
- group functions by types/packages
It runs pointer analysis to construct the call graph of the program and uses the data to generate output in dot format, which can be rendered with graphviz tools.
Ideal goal of this project is to make web app that would locally store the call graph data and then provide quick access of the call graphs for any package of your dependency tree. At first it would show an interactive map of overall dependencies between packages and then by selecting particular package it would show the call graph and provide various options to alter the output dynamically.
To install the go-callvis, use the following command:
go get -u -v github.com/TrueFurby/go-callvis
go-callvis [OPTIONS] <main pkg>
Options:
-focus string
focus package name (default: main)
-ignore string
ignore package path
-limit string
limit package path
-sub string
subgraph by [type, pkg]
Element | Style | Represents | Example |
---|---|---|---|
node color | blue | func in focused pkg |
| _yellow_ | func in other pkg | ![nonfocused](images/legend_nonfocused.png)
node border | bold | exported func | | dotted | anonymous func | edge color | black | internal calls | | brown | external calls | edge line | dashed | dynamic calls | arrow shape | empty arrow | concurrent calls | arrow shape | empty circle | deferred calls |
Here are usage examples for syncthing program.
go-callvis -focus upgrade -limit github.com/syncthing/syncthing github.com/syncthing/syncthing/cmd/syncthing | dot -Tpng -o syncthing.png
go-callvis -sub pkg -focus upgrade -limit github.com/syncthing/syncthing github.com/syncthing/syncthing/cmd/syncthing | dot -Tpng -o syncthing.png
go-callvis -ignore github.com/syncthing/syncthing/lib/logger -sub pkg -focus upgrade -limit github.com/syncthing/syncthing github.com/syncthing/syncthing/cmd/syncthing | dot -Tpng -o syncthing.png
execution takes a lot of time (~5s), because currently:
- the call graph is always generated for the entire program
- there is yet no caching of call graph data
Join the #go-callvis channel at gophers.slack.com