最新消息:yaf表单扩展中新增加了浮点数、日期和集合的校验。php yaf框架扩展实践三——表单

golang godepq查看包依赖树(import tree)

Golang 426浏览 0评论

godepq这个库和以前介绍的godep库不太一样,godepq这个库主要用来查看包中所有依赖包的关系。

github地址:https://github.com/google/godepq

安装

$ go get github.com/google/godepq

查看使用方式

$ godepq -help
Usage of godepq:
-all-paths
whether to include all paths in the result
-from string
root package
-ignore string
regular expression for packages to ignore
-include-stdlib
whether to include go standard library imports
-include-tests
whether to include test imports
-o string
{list: print path(s), dot: export dot graph} (default "list")
-to string
target package for querying dependency paths

列出库所有的导入库

$ godepq -from github.com/google/godepq
Packages:
  github.com/google/godepq
  flag
  github.com/google/godepq/pkg
  fmt
  os
  errors
  go/build
  regexp
  log

找出两个包之间的依赖路径

$ godepq -from k8s.io/kubernetes/pkg/kubelet -to k8s.io/kubernetes/pkg/master
No path found from "k8s.io/kubernetes/pkg/kubelet" to "k8s.io/kubernetes/pkg/master"
$ godepq -from k8s.io/kubernetes/pkg/kubelet -to k8s.io/kubernetes/pkg/credentialprovider
Packages:
  k8s.io/kubernetes/pkg/kubelet
  k8s.io/kubernetes/pkg/kubelet/rkt
  k8s.io/kubernetes/pkg/credentialprovider
Track down how a test package is being pulled into a production binary:

生成相关图

$ godepq -from k8s.io/kubernetes/cmd/hyperkube -to net/http/httptest -all-paths -o dot | dot -Tpng -o httptest.png
godepq生成import包树图

godepq生成import包树图

转载请注明:快乐编程 » golang godepq查看包依赖树(import tree)

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址