go list -m all 命令:
$ go list -m all |grep rsc
rsc.io/pdf v0.1.1
rsc.io/quote/v3 v3.1.0
rsc.io/sampler v1.3.0
但是我的项目不依赖于rsc.io/sampler
$ go mod why -m rsc.io/sampler
# rsc.io/sampler
(main module does not need module rsc.io/sampler)
最佳答案
因为rcs.io/quote/v3取决于它。
通过引入依赖项,您又可以引入其所有依赖项。
至于主模块不需要...
行,这在go help mod Why
帮助文本中进行了解释:
If the package or module is not referenced from the main module, the stanza will display a single parenthesized note indicating that fact.
当来自 go mod Why
的信息似乎不完整时,请尝试 go mod graph
获取完整的依赖关系图。
关于go - 为什么 "go list -m all"命令列出了我的项目中一些未使用的模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63779276/