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



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

我正在从我的一个模块和我自己的依赖项中删除一个不推荐使用的模块logrus,并希望确保我自己的代码中没有一个仍然使用它,以及哪些其他代码确实使用它

Go模块同时具有go.modgo.sum文件。在go.sum文件中,会出现未出现在go.mod文件中的模块github.com/sirupsen/logrus

当我通过删除go.sum并运行go test -v ./...来重新创建go.sum文件时,go.sum文件将使用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中没有列出?

这是模块:

  • 模块:https://github.com/grokify/goauth
  • go.mod
  • go.sum
go mod why github.com/sirupsen/logrus
# or 
go mod graph | grep logrus

最新更新