How to avoid indirect dependencies in go.mod file

Unfortunately, you can’t avoid them. Indirect dependency, is basically dependency that wasn’t listed in go.mod of your direct dependency, but is still required by it.

In your case it happens, because you use github.com/gocolly/colly v1.2.0 as dependency and v1.2.0 of this package isn’t a module, because it doesn’t contain go.mod, so all it’s dependencies are indirect and listed in your go.mod with indirect tag.

Note, that colly has go.mod in >=v2.0.0, so if you require that version, these dependencies won’t be listed as indirect in your go.mod.

Leave a Comment

tech