go-callvis
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 structure by using call graph and type relations. This is especially useful in larger projects where the complexity of the code rises.
Features
- focus specific package in a program
- group funcs by packages and/or types
- limit packages to custom prefix path
- ignore packages containing custom prefix
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.
Installation
Requirements
Install
Use the following commands to install:
go get -u github.com/TrueFurby/go-callvis
cd $GOPATH/src/github.com/TrueFurby/go-callvis
make
Usage
go-callvis [OPTIONS] <main pkg>
Options:
-focus string
Focus package with name (default: main).
-limit string
Limit package path to prefix.
-group string
Grouping by [type, pkg] (separated by comma).
-ignore string
Ignore package paths with prefix (separated by comma).
-tests
Include test code.
-debug
Enable verbose log.
-version
Show version and exit.
Legend
Packages & Types
Presented as subgraphs (clusters).
- packages have normal corners and label on the top
- types have rounded corners with label on the bottom
Represents |
Style |
focused |
blue color |
stdlib |
green color 💥 NEW! |
other |
yellow color |
Functions
Presented as nodes.
Represents |
Style |
exported |
bold border |
unexported |
normal border |
anonymous |
dotted border |
Calls
Presented as edges.
Represents |
Style |
internal |
black color |
external |
brown color |
static |
solid line |
dynamic |
dashed line |
regular |
simple arrow |
concurrent |
empty arrow arrow with empty circle ⚠ |
deferred |
empty circle arrow with empty diamond ⚠ |
Examples
Here is example for 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.
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.
Known Issues
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
Join the #go-callvis channel at gophers.slack.com