]> Cypherpunks repositories - gostls13.git/commit
cmd/go: make Tidy an option in PackageOpts rather than a separate call
authorBryan C. Mills <bcmills@google.com>
Wed, 14 Apr 2021 21:12:27 +0000 (17:12 -0400)
committerBryan C. Mills <bcmills@google.com>
Wed, 21 Apr 2021 04:23:52 +0000 (04:23 +0000)
commit81fcb18df5557943a80d27f248de43968e048aae
tree196796d5179a38ad4cf87b8d4917bb80a5077e80
parentc33ced6d8a2bb4db6896ff36cfcaac2bbdf123d1
cmd/go: make Tidy an option in PackageOpts rather than a separate call

This eliminates some awkwardly-stateful outside calls to
modload.{Disallow,Allow,}WriteGoMod.

Perhaps more importantly, it gives the loader the opportunity to
reload packages and revise dependencies after the tidied requirements
are computed. With lazy loading, dropping an irrelevant requirement
from the main module's go.mod file may (rarely) cause other test
dependencies for packages outside the main module to become
unresolved, which may require the loader to re-resolve those
dependencies, which may in turn add new roots and increase the
selected versions of modules providing other packages.

This refactoring allows the loader to iterate between tidying the
build list and reloading packages as needed, making the exact
sequencing of loading and tidying an implementation detail of the
modload package.

For #36460
For #40775

Change-Id: Ib6da3672f32153d5bd7d653d85e3672ab96cbe36
Reviewed-on: https://go-review.googlesource.com/c/go/+/310181
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/internal/modcmd/tidy.go
src/cmd/go/internal/modload/buildlist.go
src/cmd/go/internal/modload/init.go
src/cmd/go/internal/modload/load.go