golang項目代碼路徑生成
golang 存在非常多的interface 類型而又沒有辦法直觀的看到代碼。這裏可以使用 go-callvis 工具生成代碼函數調用情況。
下載安裝
下載安裝 go-callvis
go get -u github.com/TrueFurby/go-callvis
下載安裝依賴 graphviz
brew install graphviz
使用
輸入 go-callvis
go-callvis: visualize call graph of a Go program.
Usage:
go-callvis [flags] package
Package should be main package, otherwise -tests flag must be used.
Flags:
-debug
Enable verbose log.
-file string
output filename - omit to use server mode
-focus string
Focus specific package using name or import path. (default "main")
-format string
output file format [svg | png | jpg | ...] (default "svg")
-group string
Grouping functions by packages and/or types [pkg, type] (separated by comma)
-http string
HTTP service address. (default ":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)
-nodesep float
Minimum space between two adjacent nodes in the same rank (for taller output). (default 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
-tests
Include test code.
-version
Show version and exit.
需要在當前項目下執行。
go-callvis flags_xxxx content main文件路徑
如:
go-callvis -minlen 3 -focus code/src -group pkg,type code/src
最後面空格隔開指定main函數的目錄。
生成後 http://localhost:7878/ 查看。