aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/edit.go
AgeCommit message (Collapse)Author
2021-07-22[dev.cmdgo] cmd/go: replace Target with MainModules, allowing for multiple ↵Michael Matloob
targets This change replaces the Target variable that represents the main module and the pathPrefix and inGorootSrc which provide other information about the main module with a single MainModules value that represents multiple main modules and holds their path prefixes, module roots, and whether they are in GOROOT/src. In cases where the code checks Target or its previously associated variables, the code now checks or iterates over MainModules. In some cases, the code still assumes a single main module by calling MainModules.MustGetSingleMainModule. Some of those cases are correct: for instance, there is always only one main module for mod=vendor. Other cases are accompanied with TODOs and will have to be fixed in future CLs to properly support multiple main modules. This CL (and other cls on top of it) are planned to be checked into a branch to allow for those evaluating the workspaces proposal to try it hands on. For #45713 Change-Id: I3b699e1d5cad8c76d62dc567b8460de8c73a87ea Reviewed-on: https://go-review.googlesource.com/c/go/+/334932 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-30cmd/go: smooth out upgrade paths for lazy loadingBryan C. Mills
This change adds two possible upgrade paths for lazy loading: 1. Run 'go mod tidy -go=1.17'. 2. Starting in a module with no existing 'go' directive, run any 'go' command that updates the go.mod file. In the latter case, commands other than 'go mod tidy' may leave the go.mod file *very* untidy if it had non-trivial dependencies. (The 'go' invocation will promote all implicit eager dependencies to explicit lazy ones, which preserves the original module graph — most of which is not actually relevant.) 'go mod tidy -go=1.17' can be used to enable lazy loading without accidentally downgrading existing transitive dependencies. 'go mod tidy -go=1.16' can be used to disable lazy loading and clear away redundant roots in a single step (if reducing the go version), or to prune away dependencies of tests-of-external-tests (if increasing the go version). 'go mod tidy -go=1.15' can be used to add dependencies of tests-of-external-tests, although there isn't much point to that. DO NOT MERGE This change still needs an explicit test and a release note. Fixes #45094 For #36460 Change-Id: I68f057e39489dfd6a667cd11dc1e320c1ee1aec1 Reviewed-on: https://go-review.googlesource.com/c/go/+/315210 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>
2021-04-22cmd/go/internal/modload: migrate editBuildList to use a structured ↵Bryan C. Mills
requirement graph For #36460 Change-Id: Ic87d7e25402bb938d2872d33d26c4bf397776d1b Reviewed-on: https://go-review.googlesource.com/c/go/+/308517 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>
2021-04-09cmd/go/internal/modload: change mvsReqs to store roots instead of a full ↵Bryan C. Mills
build list The mvsReqs implementation has always been a bit ambivalent about whether the root requirements return the full build list, just the direct requirements, or some hybrid of the two. However, a full build list always requires the Target module as the first entry, and it's easer to remove a redundant leading element from a slice than to add one. Changing the mvsReqs field to contain arbitrary roots instead of a full build list eliminates the need to add redundant elements, at the cost of needing to remove redundant elements in more places. For #36460 Change-Id: Idd4c2d6bc7b66f67680037dab1fb9c2d1b40ab93 Reviewed-on: https://go-review.googlesource.com/c/go/+/308811 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-06cmd/go/internal/modload: track conflicts in versionLimiterBryan C. Mills
This significantly simplifies the implementation of editRequirements in preparation for making it lazy. It should have no effect on which version combinations are rejected by 'go get', nor on which solutions are found if downgrades are needed. This change results in a small but observable change in error logging. Before, we were reporting an error line for each argument that would have exceeded its specified version, attributing it to one arbitrary cause. Now, we are reporting an error line for each argument that would cause any other argument to exceed its specified version. As a result, if one argument would cause two others to exceed their versions, we will now report one line instead of two; if two arguments would independently cause one other to exceed its version, we will now report two lines instead of one. This change may result in a small performance improvement. Because we are now scanning and rejecting incompatible requirements earlier, we may waste less time computing upgrades and downgrades that ultimately won't matter due to conflicting constraints. For #36460 Change-Id: I125aa09b4be749dc5bacef23a859333991960e85 Reviewed-on: https://go-review.googlesource.com/c/go/+/305009 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
2021-03-10cmd/go/internal/modload: fuse upgrading with downgrading in EditBuildListBryan C. Mills
Previosly, EditBuildList performed an mvs.Upgrade followed by an mvs.Downgrade, with the Downgrade building on the result of the Upgrade. Unfortunately, that approach potentially folds in irrelevant dependencies from the first Upgrade, which are then preserved unnecessarily by the Downgrade (see mod_get_downup_artifact.txt). Now, we use the initial Upgrade only to compute the maximum allowed versions of transitive dependencies, and apply the module upgrades and downgrades together in a single operation. For #36460 Change-Id: I7590c137111fed4a3b06531c88d90efd49e6943a Reviewed-on: https://go-review.googlesource.com/c/go/+/290770 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>