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 function calls of your program by using call graph, package and type relations. This is especially useful in larger projects where the complexity of the code rises or when you are trying to understand someone else's code.
- focus specific package in a program
- group funcs by packages and/or types
- limit packages to custom prefix path
- ignore packages containing custom prefix
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.
Use the following commands to install:
go get -u github.com/TrueFurby/go-callvis
cd $GOPATH/src/github.com/TrueFurby/go-callvis
make
go-callvis [OPTIONS] <main pkg>
Options:
-focus string
Focus package with import path or name (default: main).
-limit string
Limit package path to prefix.
-group string
Grouping functions by [pkg, type] (separate multiple by comma).
-ignore string
Ignore package paths with prefix (separate multiple by comma).
-tests
Include test code.
-debug
Enable verbose log.
-version
Show version and exit.
- normal corners
- label on the top
- rounded corners
- label on the bottom
Represents | Style |
---|---|
focused |
blue color |
stdlib |
green color |
`other` | _yellow color_
Represents | Style |
---|---|
exported |
bold border |
unexported |
normal border |
anonymous |
dotted border |
Represents | Style |
---|---|
internal |
black color |
external |
brown color |
`static` | _solid line_
dynamic
| dashed line
regular
| simple arrow
concurrent
| arrow with empty circle
deferred
| arrow with empty diamond
Here is an example for the project syncthing.
go-callvis -focus upgrade -group pkg,type -limit github.com/syncthing/syncthing -ignore github.com/syncthing/syncthing/lib/logger github.com/syncthing/syncthing/cmd/syncthing | dot -Tpng -o syncthing.png
You can find more examples in the folder examples.
Join the channel #go-callvis at gophers.slack.com.
Are you not a member yet? Get invitation.
Feel free to open new issue or start discussion in the slack channel.
- each execution takes a lot of time, because currently:
- the call graph is always generated for the entire program
- there is yet no caching of call graph data
💥 The interactive tool described below has been published as a separate project called goexplorer.
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.