一、go-callvis介绍

Go-callvis是一种golang代码可视化工具,用于帮忙应用交互式视图可视化 Go 程序的调用图。此工具的目标是为开发人员提供一个可视化的 Go 程序概览,应用来自调用图的数据及其与包和类型的关系。这在大型项目中特地有用,因为这些我的项目的代码复杂度要高得多,或者只是简略地试图了解其他人的代码。

二、运行依赖

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

三、装置

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

或者是

git clone https://github.com/ofabry/go-callvis.gitcd go-callvismake install

装置好的 go-callvis 可执行文件会在$GOPATH/bin目录下

四、应用办法

  • 运行go-callvis -h能够列出所有受反对的选项,如下
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.        显示版本号
  • 命令行格局:go-callvis [可选参数] <包门路>
  • 默认状况下,输入的图在 http://localhost:7878/,可应用选项-http="ADDR:PORT"更改HTTP服务器地址。
  • 动态输入:

    • 要生成单个输入文件,应用选项-file=<file path>抉择输入文件指标。
    • 输入格局默认为svg,应用选项-format=<svg|png|jpg|...>抉择其余输入格局。
  • 应用示例:

    • 解析main包 go-callvis -skipbrowser -nostd ./
    • 解析testPkg包 go-callvis -group pkg,type -focus testPkg github.com/我的项目具体门路

五、效果图阐明

  • 标准阐明

参考

  • https://github.com/ofabry/go-callvis

附:有有余、疏漏欢送指出,我能够借鉴学习后补充。