1 | <p align="center"><img src="images/gopher.png" alt="gopher"></p> |
---|---|
2 | |
3 | <h1 align="center">go-callvis</h1> |
4 | |
5 | <p align="center"> |
6 | <a href="https://github.com/ofabry/go-callvis/releases"><img src="https://img.shields.io/github/release/ofabry/go-callvis.svg" alt="Github release"></a> |
7 | <a href="https://travis-ci.org/ofabry/go-callvis"><img src="https://travis-ci.org/ofabry/go-callvis.svg?branch=master" alt="Build status"></a> |
8 | <a href="https://gophers.slack.com/archives/go-callvis"><img src="https://img.shields.io/badge/gophers%20slack-%23go--callvis-ff69b4.svg" alt="Slack channel"></a> |
9 | </p> |
10 | |
11 | <p align="center"><b>go-callvis</b> is a development tool to help visualize call graph of a Go program using interactive view.</p> |
12 | |
13 | --- |
14 | |
15 | ## Introduction |
16 | |
17 | The purpose of this tool is to provide developers with a visual overview of a Go program using data from call graph |
18 | and its relations with packages and types. This is especially useful in larger projects where the complexity of |
19 | the code much higher or when you are just simply trying to understand code of somebody else. |
20 | |
21 | ### Features |
22 | |
23 | - 🆕 **support for Go modules!** :boom: |
24 | - focus specific package in the program |
25 | - click on package to quickly switch the focus using [interactive viewer](#interactive-viewer) |
26 | - group functions by package and/or methods by type |
27 | - filter packages to specific import path prefixes |
28 | - ignore funcs from standard library |
29 | - omit various types of function calls |
30 | |
31 | ### Output preview |
32 | |
33 | [](https://raw.githubusercontent.com/ofabry/go-callvis/master/images/main.png) |
34 | |
35 | > Check out the [source code](examples/main) for the above image. |
36 | |
37 | ### How it works |
38 | |
39 | It runs [pointer analysis](https://godoc.org/golang.org/x/tools/go/pointer) to construct the call graph of the program and |
40 | uses the data to generate output in [dot format](http://www.graphviz.org/content/dot-language), which can be rendered with Graphviz tools. |
41 | |
42 | ## Reference guide |
43 | |
44 | Here you can find descriptions for various types of output. |
45 | |
46 | ### Packages / Types |
47 | |
48 | |Represents | Style| |
49 | |----------: | :-------------| |
50 | |`focused` | **blue** color| |
51 | |`stdlib` | **green** color| |
52 | |`other` | **yellow** color| |
53 | |
54 | ### Functions / Methods |
55 | |
56 | |Represents | Style| |
57 | |-----------: | :--------------| |
58 | |`exported` | **bold** border| |
59 | |`unexported` | **normal** border| |
60 | |`anonymous` | **dotted** border| |
61 | |
62 | ### Calls |
63 | |
64 | |Represents | Style| |
65 | |-----------: | :-------------| |
66 | |`internal` | **black** color| |
67 | |`external` | **brown** color| |
68 | |`static` | **solid** line| |
69 | |`dynamic` | **dashed** line| |
70 | |`regular` | **simple** arrow| |
71 | |`concurrent` | arrow with **circle**| |
72 | |`deferred` | arrow with **diamond**| |
73 | |
74 | ## Quick start |
75 | |
76 | #### Requirements |
77 | |
78 | - [Go](https://golang.org/dl/) 1.17+ |
79 | - [Graphviz](http://www.graphviz.org/download/) (optional, required only with `-graphviz` flag) |
80 | |
81 | ### Installation |
82 | |
83 | ```sh |
84 | go get -u github.com/ofabry/go-callvis |
85 | # or |
86 | git clone https://github.com/ofabry/go-callvis.git |
87 | cd go-callvis && make install |
88 | ``` |
89 | |
90 | ### Usage |
91 | |
92 | #### Interactive viewer |
93 | |
94 | To use the interactive view provided by a web server that serves SVG images of focused packages, you can simply run: |
95 | |
96 | `go-callvis <target package>` |
97 | |
98 | HTTP server is listening on [http://localhost:7878/](http://localhost:7878/) by default, use option `-http="ADDR:PORT"` to change HTTP server address. |
99 | |
100 | #### Render static output |
101 | |
102 | To generate a single output file use option `-file=<file path>` to choose output file destination. |
103 | |
104 | The output format defaults to `svg`, use option `-format=<svg|png|jpg|...>` to pick a different output format. |
105 | |
106 | #### Options |
107 | |
108 | ``` |
109 | Usage of go-callvis: |
110 | -debug |
111 | Enable verbose log. |
112 | -file string |
113 | output filename - omit to use server mode |
114 | -cacheDir string |
115 | Enable caching to avoid unnecessary re-rendering. |
116 | -focus string |
117 | Focus specific package using name or import path. (default "main") |
118 | -format string |
119 | output file format [svg | png | jpg | ...] (default "svg") |
120 | -graphviz |
121 | Use Graphviz's dot program to render images. |
122 | -group string |
123 | Grouping functions by packages and/or types [pkg, type] (separated by comma) (default "pkg") |
124 | -http string |
125 | HTTP service address. (default ":7878") |
126 | -ignore string |
127 | Ignore package paths containing given prefixes (separated by comma) |
128 | -include string |
129 | Include package paths with given prefixes (separated by comma) |
130 | -limit string |
131 | Limit package paths to given prefixes (separated by comma) |
132 | -minlen uint |
133 | Minimum edge length (for wider output). (default 2) |
134 | -nodesep float |
135 | Minimum space between two adjacent nodes in the same rank (for taller output). (default 0.35) |
136 | -nointer |
137 | Omit calls to unexported functions. |
138 | -nostd |
139 | Omit calls to/from packages in standard library. |
140 | -rankdir |
141 | Direction of graph layout [LR | RL | TB | BT] (default "LR") |
142 | -skipbrowser |
143 | Skip opening browser. |
144 | -tags build tags |
145 | a list of build tags to consider satisfied during the build. For more information about build tags, see the description of build constraints in the documentation for the go/build package |
146 | -tests |
147 | Include test code. |
148 | -version |
149 | Show version and exit. |
150 | ``` |
151 | |
152 | Run `go-callvis -h` to list all supported options. |
153 | |
154 | ## Examples |
155 | |
156 | Here is an example for the project [syncthing](https://github.com/syncthing/syncthing). |
157 | |
158 | [](https://raw.githubusercontent.com/ofabry/go-callvis/master/images/syncthing.png) |
159 | |
160 | > Check out [more examples](examples) and used command options. |
161 | |
162 | ## Community |
163 | |
164 | Join [#go-callvis](https://gophers.slack.com/archives/go-callvis) channel at [gophers.slack.com](http://gophers.slack.com). (*not a member yet?* [get invitation](https://gophersinvite.herokuapp.com)) |
165 | |
166 | ### How to help |
167 | |
168 | Did you find any bugs or have some suggestions? |
169 | - Feel free to open [new issue](https://github.com/ofabry/go-callvis/issues/new) or start discussion in the slack channel. |
170 | |
171 | Do you want to contribute to the project? |
172 | - Fork the repository and open a pull request. [Here](https://github.com/ofabry/go-callvis/projects/1) you can find TODO features. |
173 | |
174 | --- |
175 | |
176 | #### Roadmap |
177 | |
178 | ##### The *interactive tool* described below has been published as a *separate project* called [goexplorer](https://github.com/ofabry/goexplorer)! |
179 | |
180 | > 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. |
181 |
Members