go.mod// indirectrequire//indirect
indirect
require (
github.com/Rican7/retry v0.1.0 // indirect
github.com/auth0/go-jwt-middleware v0.0.0-20170425171159-5493cabe49f7 // indirect
github.com/boltdb/bolt v1.3.1 // indirect
github.com/checkpoint-restore/go-criu v0.0.0-20190109184317-bdb7599cd87b // indirect
github.com/codegangsta/negroni v1.0.0 // indirect
...
)
go mod tidygo.mod// indirect// indirectimport
go.mod
go.mod
- 直接依赖未启用 Go module
- 直接依赖go.mod 文件中缺失部分依赖
直接依赖未启用 Go module
go.modgo mod tidygo.modgo.mod// indirect
go.mod
require (
B vx.x.x
B1 vx.x.x // indirect
B2 vx.x.x // indirect
)
go.mod
直接依赖 go.mod 文件不完整
go.modgo.modgo.modgo.modgo.mod
go.modgo.modgo.modgo.mod
go.mod
require (
B vx.x.x
B2 vx.x.x // indirect
)
go.modgo.mod
总结
为什么要记录间接依赖
go.modgo.mod
go.modgo.mod
如何处理间接依赖
go.modgo.mod
go.mod// indirect
出现间接依赖可能意味着你在使用过时的软件,如果有精力的话还是推荐尽快消除间接依赖。可以通过使用依赖的新版本或者替换依赖的方式消除间接依赖。
如何查找间接依赖来源
go mod whygo.modgo mod why -m
go.mod
require (
github.com/Rican7/retry v0.1.0 // indirect
github.com/google/uuid v1.0.0
github.com/renhongcai/indirect v1.0.0
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/text v0.3.2
)
github.com/Rican7/retry v0.1.0 // indirectgo mod why
[root@ecs-d8b6 gomodule]# go mod why -m github.com/Rican7/retry
# github.com/Rican7/retry
github.com/renhongcai/gomodule
github.com/renhongcai/indirect
github.com/Rican7/retry
# github.com/Rican7/retrygithub.com/renhongcai/gomodulegithub.com/renhongcai/indirectgithub.com/renhongcai/indirectgithub.com/Rican7/retrygithub.com/Rican7/retrygithub.com/renhongcai/indirect
go mod why -m all