如何快速搜索golang的包引用情况?

命令如下:

alias gos='gos(){echo $@:;grep --exclude-dir=vendor --include="*.go" -nPr "(\s|&)($@)\.[A-Z].*" || echo "nothing" ;echo "";};gos $@'

使用方法:

假设查看istio中对net包的使用情况

cd istio-1.3.5 
gos net

输出如下:

net:
tools/istio-iptables/pkg/dependencies/implementation.go:34:     addrs, err := net.InterfaceAddrs()
tools/istio-iptables/pkg/dependencies/stub.go:33:       return net.ParseIP(ip), nil
tools/istio-iptables/main.go:48:                ip, ipNet, err := net.ParseCIDR(ipRange)
tools/istio-iptables/main.go:78:        var enableInboundIPv6s net.IP

posted @ 2019-12-06 22:09  futuretea  阅读(879)  评论(0编辑  收藏  举报