aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/go/internal/modcmd/download.go3
-rw-r--r--src/cmd/go/testdata/script/mod_download.txt18
2 files changed, 21 insertions, 0 deletions
diff --git a/src/cmd/go/internal/modcmd/download.go b/src/cmd/go/internal/modcmd/download.go
index 0ea5638e70..6227fd9f33 100644
--- a/src/cmd/go/internal/modcmd/download.go
+++ b/src/cmd/go/internal/modcmd/download.go
@@ -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()
}
diff --git a/src/cmd/go/testdata/script/mod_download.txt b/src/cmd/go/testdata/script/mod_download.txt
index b9bf67cad5..c53bbe4567 100644
--- a/src/cmd/go/testdata/script/mod_download.txt
+++ b/src/cmd/go/testdata/script/mod_download.txt
@@ -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
+)