ondrajz / go-callvis

Visualize call graph of a Go program using Graphviz
https://ofabry.github.io/go-callvis
MIT License
5.91k stars 408 forks source link

Run as non-http utility (eg output SVG, PNG to a file w/o opening a web server) #36

Closed Russtopia closed 5 years ago

Russtopia commented 5 years ago

USE CASE: calling go-callvis from a Makefile to non-interactively generate an output image of dot visualization

The examples page shows usage such as

go-callvis <opts> | dot -Tpng -o output.png

However this calling style still seems to launch the web browser with output rather than just outputting a dot PNG file, making it unsuitable for use in scripts or makefiles. Piping to 'dot' util as in the examples appears not to work as go-callvis doesn't output suitable data to stdout.

EDIT: I see that while the program is running, the output is written to /tmp/go-callvis_export.svg. Basically it would be good if this were specifiable via a new option like '-output' to give a custom path, and if -skipbrowser or the presence of -output would prevent launching the web browser and have go-callvis exit after generating the SVG.

I'll work on a patch to do this and submit a pull request.

Russtopia commented 5 years ago

I have submitted pull request https://github.com/TrueFurby/go-callvis/pull/39 which implements this feature.

Very useful tool thank you!