]> Cypherpunks repositories - gostls13.git/commit
cmd/go: refactor {Allow,Disallow}WriteGoMod to ExplicitWriteGoMod
authorJay Conrod <jayconrod@google.com>
Mon, 13 Sep 2021 23:48:53 +0000 (16:48 -0700)
committerJay Conrod <jayconrod@google.com>
Fri, 24 Sep 2021 17:53:04 +0000 (17:53 +0000)
commitb00222fcdd9f2aeb426887b005865eca1aec3631
tree304e14c9cf1259263f349688d364e65168efafe9
parent584afc29289c2f1a204daa39f44a4a4afbacb741
cmd/go: refactor {Allow,Disallow}WriteGoMod to ExplicitWriteGoMod

Subcommands may now set the global flag modload.ExplicitWriteGoMod
instead of calling {Allow,Disallow}WriteGoMod.

When ExplicitWriteGoMod is false (default), modload.LoadPackages and
ListModules will either update go.mod and go.sum or report an error if
they need to be updated, depending on cfg.BuildMod.

When ExplicitWriteGoMod is true, commands must explicitly call
modload.WriteGoMod to update go.mod and go.sum or report an
error. Commands that perform some operation after loading the build
list (like downloading zips or building packages) and commands that
load packages multiple times should set this. For now, only 'go get'
and 'go mod download' set this.

This CL is a pure refactor: no change in behavior is expected.
There are some other minor changes in here, too: commitRequirements no
longer sets the global requirements: that should be done separately first.

Change-Id: I69942a808bb177faf7904a53aaf2d4ac68500e82
Reviewed-on: https://go-review.googlesource.com/c/go/+/349600
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/internal/modcmd/download.go
src/cmd/go/internal/modcmd/why.go
src/cmd/go/internal/modget/get.go
src/cmd/go/internal/modload/buildlist.go
src/cmd/go/internal/modload/init.go
src/cmd/go/internal/modload/list.go
src/cmd/go/internal/modload/load.go