我正在使用"github.com/gocolly/colly v1.2.0“运行go build来更新我的go.mod文件的库,但我看到所有其他依赖项在末尾都写着"//间接”。如何避免这种情况?这是我的go.mod文件
module prodenv
go 1.13
require (
github.com/PuerkitoBio/goquery v1.5.1 // indirect
github.com/antchfx/htmlquery v1.2.2 // indirect
github.com/antchfx/xmlquery v1.2.3 // indirect
github.com/antchfx/xpath v1.1.5 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gocolly/colly v1.2.0
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/kennygrant/sanitize v1.2.4 // indirect
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
github.com/temoto/robotstxt v1.1.1 // indirect
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
google.golang.org/appengine v1.6.5 // indirect
)发布于 2020-04-09 15:14:23
不幸的是,你无法避免它们。间接依赖,基本上是没有在直接依赖的go.mod中列出的依赖,但它仍然是必需的。
在您的例子中,会发生这种情况,因为您使用github.com/gocolly/colly v1.2.0作为依赖项,而这个包的v1.2.0不是一个模块,因为它不包含go.mod,所以它的所有依赖项都是间接的,并在带有indirect的go.mod标记中列出。
请注意,colly在>=v2.0.0中具有go.mod,因此如果您需要该版本,则这些依赖项不会在您的go.mod中作为间接项列出。
https://stackoverflow.com/questions/61115111
复制相似问题