]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: make 'go mod download' update go.sum after downloads are complete
authorJay Conrod <jayconrod@google.com>
Fri, 11 Sep 2020 13:31:30 +0000 (09:31 -0400)
committerJay Conrod <jayconrod@google.com>
Fri, 11 Sep 2020 15:53:52 +0000 (15:53 +0000)
'go mod download' calls WriteGoMod once via modload.ListModules when
it loads the build list. This saves sums for go.mod files needed by
MVS, but the write occurs before any zip files are downloaded.

With this change, 'go mod download' calls WriteGoMod again (and thus,
modfetch.WriteGoSum) after downloading and verifying module zip files,
so the sums of the zip files will be saved, too.

Fixes #41341

Change-Id: I7d56754aa255256ed45fd93cb154c2e6ea5f45a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/254357
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/internal/modcmd/download.go
src/cmd/go/testdata/script/mod_download.txt

index 0ea5638e703c377252abd4d8536120b953c1e173..6227fd9f33dda5a1ea8e1f507fc25975adfb8796 100644 (file)
@@ -187,4 +187,7 @@ func runDownload(ctx context.Context, cmd *base.Command, args []string) {
                }
                base.ExitIfErrors()
        }
+
+       // Update go.mod and especially go.sum if needed.
+       modload.WriteGoMod()
 }
index b9bf67cad59679fa419607de0f76dc374593b16a..c53bbe456743f39ccd57e54e21ab6718d7297f10 100644 (file)
@@ -107,6 +107,14 @@ stderr '^go mod download: skipping argument m that resolves to the main module\n
 go mod download m@latest
 stderr '^go mod download: skipping argument m@latest that resolves to the main module\n'
 
+# download updates go.mod and populates go.sum
+cd update
+! exists go.sum
+go mod download
+grep '^rsc.io/sampler v1.3.0 ' go.sum
+go list -m rsc.io/sampler
+stdout '^rsc.io/sampler v1.3.0$'
+
 # allow go mod download without go.mod
 env GO111MODULE=auto
 rm go.mod
@@ -122,3 +130,13 @@ stderr 'get '$GOPROXY
 
 -- go.mod --
 module m
+
+-- update/go.mod --
+module m
+
+go 1.16
+
+require (
+       rsc.io/quote v1.5.2
+       rsc.io/sampler v1.2.1 // older version than in build list
+)