Skip to content

Commit b459bc8

Browse files
author
Jay Conrod
committed
cmd/go: make 'go mod download' update go.sum after downloads are complete
'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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent 1ed4f12 commit b459bc8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/cmd/go/internal/modcmd/download.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,7 @@ func runDownload(ctx context.Context, cmd *base.Command, args []string) {
187187
}
188188
base.ExitIfErrors()
189189
}
190+
191+
// Update go.mod and especially go.sum if needed.
192+
modload.WriteGoMod()
190193
}

src/cmd/go/testdata/script/mod_download.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ stderr '^go mod download: skipping argument m that resolves to the main module\n
107107
go mod download m@latest
108108
stderr '^go mod download: skipping argument m@latest that resolves to the main module\n'
109109

110+
# download updates go.mod and populates go.sum
111+
cd update
112+
! exists go.sum
113+
go mod download
114+
grep '^rsc.io/sampler v1.3.0 ' go.sum
115+
go list -m rsc.io/sampler
116+
stdout '^rsc.io/sampler v1.3.0$'
117+
110118
# allow go mod download without go.mod
111119
env GO111MODULE=auto
112120
rm go.mod
@@ -122,3 +130,13 @@ stderr 'get '$GOPROXY
122130

123131
-- go.mod --
124132
module m
133+
134+
-- update/go.mod --
135+
module m
136+
137+
go 1.16
138+
139+
require (
140+
rsc.io/quote v1.5.2
141+
rsc.io/sampler v1.2.1 // older version than in build list
142+
)

0 commit comments

Comments
 (0)