从模块中获取包列表的方法 - Golang实践指南
从模块中获取包列表的方法 - Golang实践指南 我们有一个包含许多包的Go模块。 例如:
go list github.com/myco/bigmodule/...
github.com/myco/bigmodule
github.com/myco/bigmodule/pkg1
github.com/myco/bigmodule/pkg2
github.com/myco/bigmodule/suspkg
github.com/myco/bigmodule/pkg4
在我们的例子中,这个列表大约有50个包长。其中有一个包存在问题,我们想在所有代码仓库中搜索对该特定包的使用。
我可以执行 go list -m all 来查看一个仓库是否使用了这个大模块。
但我需要找出该仓库是否使用了某个特定的包。
也就是说,这个仓库是否使用了这个包: github.com/myco/bigmodule/suspkg
我希望有一种方法,不需要搜索整个源代码树。
有没有一种方法可以让 go list 返回正在使用的特定包?
更多关于从模块中获取包列表的方法 - Golang实践指南的实战教程也可以访问 https://www.itying.com/category-94-b0.html
2 回复
如果代码是公开的,那么 pkg.go.dev 会提供一个“被导入”的列表。
以下是我的一个库的示例:https://pkg.go.dev/github.com/ncw/directio?tab=importedby
更多关于从模块中获取包列表的方法 - Golang实践指南的实战系列教程也可以访问 https://www.itying.com/category-94-b0.html


