golang go-callvis

目的

环境

环境版本说明
OScentos7
golang1.12.6
go-callvislastesthttps://github.com/TrueFurby/go-callvis

软件获取方法

go get -u github.com/syncthing/syncthing
go get -u github.com/TrueFurby/go-callvis

目录结构

.
└── github.com
    ├── syncthing
    │   └── syncthing          <-  go-callvis 插件
    └── TrueFurby
        └── go-callvis

vendor 下载方法

新版本 golang 已经可以不使用 go get 方法获取第三方包
可以使用 go mod 获取第三方包
需编写 go.mod 文件

go.mod

一般情况下都放下项目下
一般都需要指定 go 1.12 版本或以上
不需要使用到 GOPATH 设定, 执行 unset GOPATH 即可

参考 go.mod 文件

module github.com/syncthing/syncthing            <- 会在这里自己创建了 vendor 并下载第三方包到这里

require (
        github.com/AudriusButkevicius/go-nat-pmp v0.0.0-20160522074932-452c97607362
        github.com/AudriusButkevicius/pfilter v0.0.0-20190627213056-c55ef6137fc6
        github.com/AudriusButkevicius/recli v0.0.5
        ...... 其他需要的包
}
go 1.12

go proxy 使用

可以加速下载第三方软件包

export GOPROXY=https://goproxy.cn

下载 vendor

go mod vendor 执行命令即可

安装方法

先编译插件

# # cd github.com/syncthing/syncthing
# ./build.sh
golang.org/x/net/internal/iana
github.com/petermattis/goid
golang.org/x/sys/unix
.....
github.com/syncthing/syncthing/cmd/uraggregate
github.com/syncthing/syncthing/cmd/ursrv
ok      github.com/syncthing/syncthing/meta     0.003s

编译 go-callvis

cd github.com/TrueFurby/go-callvis/
go mod vendor
make install

验证命令

# ./go-callvis -h
Usage of ./go-callvis:
  -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 -group pkg,type  -http "0.0.0.0:7777"   -limit github.com/syncthing/syncthing -ignore github.com/syncthing/syncthing/lib/logger github.com/syncthing/syncthing/cmd/syncthing

可通过浏览器访问 ip:7777 查询流程图

不过这个流程图关心的是 GOLANG 底层的运行方法, 不是关心你的函数调用方法

参考官方图

在这里插入图片描述

错误解决方法

错误信息

# go-callvis -focus upgrade -group pkg,type -limit github.com/syncthing/syncthing -ignore github.com/syncthing/syncthing/lib/logger github.com/syncthing/syncthing/cmd/syncthing
/usr/src/go/src/runtime/cgo/cgo.go:29:8: could not import C (no metadata for C)
/usr/src/go/src/net/cgo_linux.go:12:8: could not import C (no metadata for C)
/usr/src/go/src/os/user/cgo_lookup_unix.go:46:8: could not import C (no metadata for C)
2019/11/01 16:59:14 packages contain errors

上面错误时因为缺少了 c 的库
解决办法

yum install -y gcc-devel gcc-c++-devel

错误信息:

2019/11/01 17:01:57 OpenURL error: exec: "xdg-open": executable file not found in $PATH

解决办法

yum install -y xdg-utils

错误信息

 unable to find program 'dot'

解决方法

yum install graphviz	
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Terry_Tsang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值