头图

1. Introduction to go-callvis

go-callvis is a golang code visualizer to help visualize the call graph of a Go program using an interactive view. The purpose of this tool is to provide developers with a visual overview of a Go program, using data from the call graph and its relationship to packages and types. This is especially useful in larger projects where the code complexity is much higher, or simply trying to understand other people's code.

2. Operational dependencies

  • Go 1.13+
  • Graphviz (optional, required only with -graphviz flag)

3. Installation

go get -u github.com/ofabry/go-callvis

or

git clone https://github.com/ofabry/go-callvis.git
cd go-callvis
make install

The installed go-callvis executable will be in the $GOPATH/bin directory

4. How to use

  • Running go-callvis -h lists all supported options as follows
Usage of go-callvis:
  -debug
        Enable verbose log.
        输出详细日志
  -file string
        output filename - omit to use server mode
        以文件新式输出结果,并将忽略server交互模式
  -cacheDir string
        Enable caching to avoid unnecessary re-rendering.
        启用缓存以避免不必要的重新渲染。
  -focus string
        Focus specific package using name or import path. (default "main")
        关注特定的程序包,默认为“main”包
  -format string
        output file format [svg | png | jpg | ...] (default "svg")
        输出文件的格式,[svg | png | jpg | ...],默认为svg
  -graphviz
        Use Graphviz's dot program to render images.
        使用Graphviz渲染图像
  -group string
        Grouping functions by packages and/or types [pkg, type] (separated by comma) (default "pkg")
        分组功能,根据包 与/或 类型分组 [pkg, type] (用逗号分开) (默认 "pkg"),例如 -group pkg,type
  -http string
        HTTP service address. (default ":7878")
        HTTP 服务地址 (默认 ":7878")
  -ignore string
        Ignore package paths containing given prefixes (separated by comma)
        忽略包含给定前缀的包路径(用逗号分开)
  -include string
        Include package paths with given prefixes (separated by comma)
        包含具有给定前缀的包路径 (用逗号分开)
  -limit string
        Limit package paths to given prefixes (separated by comma)
        将包路径限制为给定的前缀(以逗号分隔)
  -minlen uint
        Minimum edge length (for wider output). (default 2)
        最小边长(用于更宽的输出)。 (默认2)
  -nodesep float
        Minimum space between two adjacent nodes in the same rank (for taller output). (default 0.35)
        同一等级中两个相邻节点之间的最小间距(用于更高的输出)。 (默认0.35)
  -nointer
        Omit calls to unexported functions.
        忽略对未导出函数的调用。(忽略首字母小写的函数)
  -nostd
        Omit calls to/from packages in standard library.
        忽略标准库的调用
  -skipbrowser
        Skip opening browser.
        跳过打开浏览器
  -tags build tags
        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
        在构建期间更适合的构建标记
        有关构建标记的更多信息,请参阅go / build软件包的文档中的构建约束说明。
  -tests
        Include test code.
        包含测试代码
  -version
        Show version and exit.
        显示版本号
  • Command line format: go-callvis [optional parameters] <package path>
  • By default, the output graph is at http://localhost:7878/ , the HTTP server address -http="ADDR:PORT"
  • Static output:

    • To generate a single output file, use option -file=<file path> select the output file destination.
    • The output format defaults to svg, use option -format=<svg|png|jpg|...> choose other output formats.
  • Example of use:

    • Parse the main package go-callvis -skipbrowser -nostd ./
    • Parse the testPkg package go-callvis -group pkg,type -focus testPkg github.com/project specific path

5. Description of renderings

请添加图片描述

  • Specification

refer to

Attachment: If there are any deficiencies or omissions, please point out. I can learn from them and supplement them.


土豆
17 声望5 粉丝