go - 为什么 "go list -m all"命令列出了我的项目中一些未使用的模块?

标签 go go-modules

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/

相关文章:

go - 如何让golang的Logrus通过多个文件共享同一个config?

go - Route53 : query domain records by Domain Name

go - cgo 和某些字符串 slice 的运行时错误

Go Modules 无法识别 GOPATH 下的文件

go - 修复所有给出 "go: error loading module requirements"的 Go 命令?

curl - 使用 GoLang 通过curl 发送多部分请求

go - 通过 Jenkins 工具安装 go-1.17 时输入格式错误或输入包含不可映射的字符

go - 如何修复 gomod : `github.com/stretchrcom/testify@v1.4.0: parsing go.mod: unexpected module path "github. com/strethr/testify"`

go - "go mod tidy"与 "go build"的行为

go - 不能在非本地类型模型上定义新方法。Meter