繁体   English   中英

如何使用 Go 模块识别依赖链

[英]How to identify dependency chain using Go Modules

如何识别存在于go.sum但不存在于go.mod中的模块的导入路径? 我想知道 go.mod 中的哪个模块正在导入go.mod中列出的go.sum ,以及它们之间的整个链。

我正在从我的一个模块和我自己的依赖项中删除一个已弃用的模块logrus ,并希望确保我自己的代码中没有一个仍在使用它,并且其他代码确实使用了它。

Go 模块具有go.modgo.sum文件。 go.sum文件中,出现了一个模块github.com/sirupsen/logrus ,它没有出现在go.mod文件中。

When I recreate the go.sum file by deleting go.sum and running go test -v./... , the go.sum file is recreated with logrus .

go.mod中没有直接或间接提及,例如:

github.com/sirupsen/logrus v1.6.0 // indirect

go mod why返回以下内容:

$ go mod why github.com/sirupsen/logrus
# github.com/sirupsen/logrus
(main module does not need package github.com/sirupsen/logrus)

go mod why -m返回以下内容:

$ go mod why -m github.com/sirupsen/logrus
# github.com/sirupsen/logrus
(main module does not need module github.com/sirupsen/logrus)

如何找出go.mod中的哪个模块正在导入一个模块logrus ,该模块在go.sum中列出,但不在go.mod

这是模块:

go mod why github.com/sirupsen/logrus
# or 
go mod graph | grep logrus

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM