Skip to content

Latest commit

 

History

History
147 lines (99 loc) · 4.8 KB

README.md

File metadata and controls

147 lines (99 loc) · 4.8 KB

gopher

Github release Build status Slack channel

go-callvis

go-callvis is a development tool to help visualize call graph of your Go program using Graphviz's dot format.

main

Introduction

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.

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.

Get started

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 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.

Legend

Packages & Types

Presented as subgraphs (clusters).
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

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 | arrow with empty circle deferred | arrow with empty diamond

Examples

Here is an example for the project syncthing.

syncthing example

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.

Community

Join the channel #go-callvis at gophers.slack.com.

Are you not a member yet? Get invitation.

How to contribute

Did you find any bugs or have some suggestions?

Feel free to open new issue or start discussion in the slack channel.

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

💥 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.