exclude directives in the go.mod file prevent commands such as go get -u from selecting particular versions of modules.
However, if the active version of a dependency is already semantically higher than the excluded version, go get -u would never select that version implicitly in the first place (depending on the resolution of #26474). The only time it could be introduced is by an explicit downgrade of some package, and explicit downgrades — though possible — are likely to be rare in practice.
That makes those exclude directives noisy and somewhat misleading: they appear to have an effect on version selection, but may actually be very stale and completely irrelevant.
I propose that go mod tidy should remove exclude directives if the selected version of the module in question is already higher than the excluded version.
(CC @rsc @jayconrod)
excludedirectives in thego.modfile prevent commands such asgo get -ufrom selecting particular versions of modules.However, if the active version of a dependency is already semantically higher than the excluded version,
go get -uwould never select that version implicitly in the first place (depending on the resolution of #26474). The only time it could be introduced is by an explicit downgrade of some package, and explicit downgrades — though possible — are likely to be rare in practice.That makes those
excludedirectives noisy and somewhat misleading: they appear to have an effect on version selection, but may actually be very stale and completely irrelevant.I propose that
go mod tidyshould removeexcludedirectives if the selected version of the module in question is already higher than the excluded version.(CC @rsc @jayconrod)