Description
go version devel go1.17-9e0facd26e Wed May 5 04:48:30 2021 +0000 linux/amd64
With the new lazy module loading introduced recently, a go.mod
file will contain all indirect dependencies, not just the ones which lack go.mod
files. This can make it hard to see the direct dependencies because they're obscured by all the indirect dependencies. As an example, in the first repository I tried, the number of indirect dependencies listed rose from 52 to 157, against 123 direct dependencies.
Although indirect dependencies are important, we should mostly be considering the direct dependencies when adjusting version numbering. It also makes it more likely that people resolving conflicts might get things wrong by choosing the wrong indirect versions.
As a way of avoiding this issue, it might be a good idea to format indirect dependencies in their own require
section.
For example:
module m
go 1.17
require (
github.com/foo/bar v1.2.3
)
require (
github.com/baz v1.0.0 // indirect
)
Perhaps even consider supporting a whole-directive indirect
comment rather than line-by-line:
// indirect
require (
github.com/baz v1.0.0
)