如何列出 Go 源代码目录中导入的模块?

huangapple go评论73阅读模式
英文:

How to list imported module on a go source code directory

问题

有没有一种工具或最简单的方法可以列出 Go 源代码目录中导入的所有包?例如:

$ go list_imports a_directory/
github.com/bla/bla
github.com/foo/bar
LOCAL/module/path
英文:

Is there an tool or easiest way to list all imported packages on go source code directory? for example:

$ go list_imports a_directory/
github.com/bla/bla
github.com/foo/bar
LOCAL/module/path

答案1

得分: 0

啊,找到了方法

go list -f '{{join .Deps "\n"}}' | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}} ' | sort | uniq
英文:

Ah found the way..

go list -f '{{join .Deps "\n"}}' |  xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}} ' | sort | uniq

huangapple
  • 本文由 发表于 2015年2月25日 11:05:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/28710397.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定