go-callvis
go-callvis is a development tool to help visualize call graph of your Go program using Graphviz's dot format.
Introduction
Purpose of this tool is to provide a visual overview of your program by using the data from call graph and its relations with packages and types. This is especially useful in larger projects where the complexity of the code rises or when you are just simply trying to understand code structure of somebody else.
Features
- focus specific package in a program
- group functions by package and methods by type
- limit packages to custom path prefixes
- ignore packages containing path prefixes
- omit calls from/to std packages
Output preview
Check out the source code for the above image.
How it works
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.
Reference guide
Here you can find descriptions for all possible kinds of calls and groups.
Packages / Types
Represented as subgraphs (clusters) in output.
Packages
- normal corners
- label on the top
Types
- rounded corners
- label on the bottom
Represents |
Style |
focused |
blue color |
stdlib |
green color |
other |
yellow color |
Functions / Methods
Represented as nodes in output.
Represents |
Style |
exported |
bold border |
unexported |
normal border |
anonymous |
dotted border |
Calls
Represented as edges in output.
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 |
Quick start
Requirements
Installation
go get -u github.com/TrueFurby/go-callvis
cd $GOPATH/src/github.com/TrueFurby/go-callvis && make
Usage
go-callvis [OPTIONS] <main pkg> | dot -Tpng -o output.png
Options
-focus string
Focus package with import path or name. (default: main)
-limit string
Limit package paths to prefix. (separate multiple by comma)
-group string
Grouping functions by [pkg, type]. (separate multiple by comma)
-ignore string
Ignore package paths with prefix. (separate multiple by comma)
-nostd
Omit calls from/to std packages.
-minlen uint
Minimum edge length (for wider output). (default: 2)
-nodesep float
Minimum space between two adjacent nodes in the same rank (for taller output). (default: 0.35)
Examples
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.
How to help
Did you find any bugs or have some suggestions?
Feel free to open new issue or start discussion in the slack channel.
Do you want to contribute to the development?
Fork the project and do a pull request. Here you can find the state of features.
Known Issues
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
Roadmap
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.