]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/go: don't let 'go mod download' save sums for inconsistent requirements
authorJay Conrod <jayconrod@google.com>
Mon, 24 May 2021 20:47:45 +0000 (16:47 -0400)
committerJay Conrod <jayconrod@google.com>
Thu, 27 May 2021 20:38:20 +0000 (20:38 +0000)
commit0ece95a0feafe151cadf1346464952bb5c95fab3
tree3d4e9b8e4ca958a4dbd62d202c641047b06f783b
parentcdcd02842da7c004efd023881e3719105209c908
cmd/go: don't let 'go mod download' save sums for inconsistent requirements

'go mod download' calls modload.LoadModFile early to find the main
module path in order to validate arguments. LoadModFile may write
go.mod and go.sum to fix formatting and add a go directive. This calls
keepSums, which, in eager mode, loaded the complete module graph in
order to find out what sums are needed to load the complete module
graph. If go.mod requires a lower version of a module than will be
selected later, keepSums causes the sum for that version's go.mod to
be retained, even though it isn't needed later after a consistent
go.mod is written.

This CL fixes keepSums not to load the graph if it hasn't already been
loaded (whether eager or lazy), addressing comments from CL 318629.

For #45332

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