se77en / go-callvis

Visualize call graph of your Go program using dot format.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-callvis Build Status

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

example

Intended purpose of this tool is to provide a visual overview of your program's source code by using call graph and type relations. This is especially useful in larger projects where the complexity of the structure rises.

Features

  • focus specific package in program
  • limit to include only packages containing prefix
  • ignore multiple packages containing prefix
  • group functions by types/packages

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.

Project goal

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.

Installation

Requirements

Install

To install the go-callvis, use the following command:

go get -u -v github.com/TrueFurby/go-callvis

Usage

go-callvis [OPTIONS] <main pkg>

Options:
  -focus string
        focus package name (default: main)
  -ignore string
        ignore package path
  -limit string
        limit package path
  -sub string
        subgraph by [type, pkg]

Legend

Element Style Represents Example
node color blue func in focused pkg focused
            | _yellow_       |  func in other pkg  | ![nonfocused](images/legend_nonfocused.png)

node border | bold | exported func | exported | dotted | anonymous func | anonymous edge color | black | internal calls | outside | brown | external calls | outside edge line | dashed | dynamic calls | dynamic arrow shape | empty arrow | concurrent calls | concurrent arrow shape | empty circle | deferred calls | deferred

Examples

Here are usage examples for syncthing program.

Focusing package upgrade

syncthing example output

go-callvis -focus upgrade -limit github.com/syncthing/syncthing github.com/syncthing/syncthing/cmd/syncthing | dot -Tpng -o syncthing.png

Grouping by packages

syncthing example output pkg

go-callvis -sub pkg -focus upgrade -limit github.com/syncthing/syncthing github.com/syncthing/syncthing/cmd/syncthing | dot -Tpng -o syncthing.png

Ignoring package logger

syncthing example output ignore

go-callvis -ignore github.com/syncthing/syncthing/lib/logger -sub pkg -focus upgrade -limit github.com/syncthing/syncthing github.com/syncthing/syncthing/cmd/syncthing | dot -Tpng -o syncthing.png

Known Issues

execution takes a lot of time (~5s), because currently:

  • the call graph is always generated for the entire program
  • there is yet no caching of call graph data

Community

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

About

Visualize call graph of your Go program using dot format.

License:MIT License


Languages

Language:Go 100.0%