简体   繁体   English

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

[英]How to identify dependency chain using Go Modules

How can I identify the import path of a module that exists in go.sum but not in go.mod ?如何识别存在于go.sum但不存在于go.mod中的模块的导入路径? I'd like to know which module in go.mod is importing the module listed in go.sum , and the entire chain between them.我想知道 go.mod 中的哪个模块正在导入go.mod中列出的go.sum ,以及它们之间的整个链。

I'm in the process of removing a deprecated module, logrus , from one of my modules and my own dependencies and want to ensure none of my own code still uses it, and which other code does use it.我正在从我的一个模块和我自己的依赖项中删除一个已弃用的模块logrus ,并希望确保我自己的代码中没有一个仍在使用它,并且其他代码确实使用了它。

The Go module has both a go.mod and a go.sum file. Go 模块具有go.modgo.sum文件。 In the go.sum file, a module github.com/sirupsen/logrus appears that does not appear in the go.mod file.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 . When I recreate the go.sum file by deleting go.sum and running go test -v./... , the go.sum file is recreated with logrus .

There is no direct or indirect mention in go.mod , such as: go.mod中没有直接或间接提及,例如:

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

go mod why returns the following: 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 returns the following: 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)

How can I find out what module in go.mod is importing a module, logrus , which is listed in go.sum but not go.mod ?如何找出go.mod中的哪个模块正在导入一个模块logrus ,该模块在go.sum中列出,但不在go.mod

Here's the module:这是模块:

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