From 016e13df7475329c65524b2eabbc5207ceb4ee74 Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Mon, 29 Jun 2020 16:28:18 -0400 Subject: [PATCH] cmd/go/internal/modfetch: stop migrating go.modverify to go.sum go.modverify was renamed to go.sum before vgo was merged into cmd/go. It's been long enough that we can safely drop support for it. For #25525 Change-Id: If8da66280a0fb6a4d4db0b170700775523c18571 Reviewed-on: https://go-review.googlesource.com/c/go/+/240458 Run-TryBot: Jay Conrod TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills --- src/cmd/go/internal/modfetch/fetch.go | 31 +++-------------------- src/cmd/go/testdata/script/mod_verify.txt | 8 +++--- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/src/cmd/go/internal/modfetch/fetch.go b/src/cmd/go/internal/modfetch/fetch.go index fd7a5cef83..8df2289097 100644 --- a/src/cmd/go/internal/modfetch/fetch.go +++ b/src/cmd/go/internal/modfetch/fetch.go @@ -374,12 +374,11 @@ type modSum struct { var goSum struct { mu sync.Mutex - m map[module.Version][]string // content of go.sum file (+ go.modverify if present) + m map[module.Version][]string // content of go.sum file checked map[modSum]bool // sums actually checked during execution dirty bool // whether we added any new sums to m overwrite bool // if true, overwrite go.sum without incorporating its contents enabled bool // whether to use go.sum at all - modverify string // path to go.modverify, to be deleted } // initGoSum initializes the go.sum data. @@ -403,19 +402,6 @@ func initGoSum() (bool, error) { goSum.enabled = true readGoSum(goSum.m, GoSumFile, data) - // Add old go.modverify file. - // We'll delete go.modverify in WriteGoSum. - alt := strings.TrimSuffix(GoSumFile, ".sum") + ".modverify" - if data, err := renameio.ReadFile(alt); err == nil { - migrate := make(map[module.Version][]string) - readGoSum(migrate, alt, data) - for mod, sums := range migrate { - for _, sum := range sums { - addModSumLocked(mod, sum) - } - } - goSum.modverify = alt - } return true, nil } @@ -616,14 +602,9 @@ func WriteGoSum() { goSum.mu.Lock() defer goSum.mu.Unlock() - if !goSum.enabled { - // If we haven't read the go.sum file yet, don't bother writing it: at best, - // we could rename the go.modverify file if it isn't empty, but we haven't - // needed to touch it so far — how important could it be? - return - } - if !goSum.dirty { - // Don't bother opening the go.sum file if we don't have anything to add. + if !goSum.enabled || !goSum.dirty { + // If we haven't read go.sum yet or if we don't have anything to add, + // don't bother opening it. return } if cfg.BuildMod == "readonly" { @@ -674,10 +655,6 @@ func WriteGoSum() { goSum.checked = make(map[modSum]bool) goSum.dirty = false goSum.overwrite = false - - if goSum.modverify != "" { - os.Remove(goSum.modverify) // best effort - } } // TrimGoSum trims go.sum to contain only the modules for which keep[m] is true. diff --git a/src/cmd/go/testdata/script/mod_verify.txt b/src/cmd/go/testdata/script/mod_verify.txt index 646bc62bb7..3918400435 100644 --- a/src/cmd/go/testdata/script/mod_verify.txt +++ b/src/cmd/go/testdata/script/mod_verify.txt @@ -12,20 +12,18 @@ go mod verify ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip # With bad go.sum, sync (which must download) fails. -# Even if the bad sum is in the old legacy go.modverify file. rm go.sum -cp go.sum.bad go.modverify +cp go.sum.bad go.sum ! go mod tidy stderr 'checksum mismatch' ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip -# With good go.sum, sync works (and moves go.modverify to go.sum). +# With good go.sum, sync works. rm go.sum -cp go.sum.good go.modverify +cp go.sum.good go.sum go mod tidy exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip exists $GOPATH/pkg/mod/rsc.io/quote@v1.1.0/quote.go -! exists go.modverify # go.sum should have the new checksum for go.mod grep '^rsc.io/quote v1.1.0/go.mod ' go.sum