Visualize call graph of a Go program using Graphviz
Visualize call graph of a Go program using Graphviz
go-callvis is a development tool to help visualize call graph of a Go program using interactive view.
The purpose of this tool is to provide developers with a visual overview of a Go program using data from call graph and its relations with packages and types. This is especially useful in larger projects where the complexity of the code much higher or when you are just simply trying to understand code of somebody else.
Check out the source code for the above image.
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.
To install go-callvis, run:
# Latest release
go install github.com/ofabry/go-callvis@latest
# Development version
go install github.com/ofabry/go-callvis@masterAlternatively, clone the repository and compile the source code:
# Clone repository
git clone https://github.com/ofabry/go-callvis.git
cd go-callvis
# Compile and install
make installTo use the interactive view provided by a web server that serves SVG images of focused packages, you can simply run:
go-callvis <target package>
HTTP server is listening on http://localhost:7878/ by default, use option -http="ADDR:PORT" to change HTTP server address.
To generate a single output file use option -file=<file path> to choose output file destination.
The output format defaults to svg, use option -format=<svg|png|jpg|...> to pick a different output format.
…Run go-callvis -h to list all supported options.
Here you can find descriptions for various types of output.
| 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 circle |
deferred |
arrow with diamond |
Here is an example for the project syncthing.
Check out more examples and used command options.
Join #go-callvis channel at gophers.slack.com. (not a member yet? get invitation)
Did you find any bugs or have some suggestions?
Do you want to contribute to the project?
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.
feature: Add flag to show function argument types in visualization
after call show error module closed with exit_code()
zsh: killed go-callvis
Focus on function instead of package
Graph from "main" callgraph.Node with depth control
Sub-module call graph visualization problem.
README to explain `<target package>`
warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
Requesting dot format
Breaking up large graphs