]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "cmd/go: group 'go get' update messages together near the end of output"
authorAustin Clements <austin@google.com>
Sat, 30 May 2020 20:40:58 +0000 (20:40 +0000)
committerAustin Clements <austin@google.com>
Sun, 31 May 2020 00:38:00 +0000 (00:38 +0000)
This reverts https://golang.org/cl/232578.

Reason for revert: This commit broke TestScript/mod_load_badchain,
which is causing all longtest builders to fail.

Change-Id: I4a17392ce74ac3a7ad340980556025f669d94b65
Reviewed-on: https://go-review.googlesource.com/c/go/+/235857
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
src/cmd/go/internal/modget/get.go
src/cmd/go/testdata/script/mod_get_update_log.txt [deleted file]

index 0bf9eb3a0485895567e3d8434d54b54e2e39019b..4c6982426fb0c4d34685d41ce523c1da55e44ec0 100644 (file)
@@ -6,10 +6,8 @@
 package modget
 
 import (
-       "bytes"
        "errors"
        "fmt"
-       "io"
        "os"
        "path/filepath"
        "sort"
@@ -704,12 +702,6 @@ func runGet(cmd *base.Command, args []string) {
        modload.AllowWriteGoMod()
        modload.WriteGoMod()
 
-       // Print the changes we made.
-       // TODO(golang.org/issue/33284): include more information about changes to
-       // relevant module versions due to MVS upgrades and downgrades. For now,
-       // the log only contains messages for versions resolved with getQuery.
-       writeUpdateLog()
-
        // If -d was specified, we're done after the module work.
        // We've already downloaded modules by loading packages above.
        // Otherwise, we need to build and install the packages matched by
@@ -1042,28 +1034,11 @@ func (r *lostUpgradeReqs) Required(mod module.Version) ([]module.Version, error)
        return r.Reqs.Required(mod)
 }
 
-var updateLog struct {
-       mu     sync.Mutex
-       buf    bytes.Buffer
-       logged map[string]bool
-}
+var loggedLines sync.Map
 
 func logOncef(format string, args ...interface{}) {
        msg := fmt.Sprintf(format, args...)
-       updateLog.mu.Lock()
-       defer updateLog.mu.Unlock()
-       if updateLog.logged == nil {
-               updateLog.logged = make(map[string]bool)
-       }
-       if updateLog.logged[msg] {
-               return
+       if _, dup := loggedLines.LoadOrStore(msg, true); !dup {
+               fmt.Fprintln(os.Stderr, msg)
        }
-       updateLog.logged[msg] = true
-       fmt.Fprintln(&updateLog.buf, msg)
-}
-
-func writeUpdateLog() {
-       updateLog.mu.Lock()
-       defer updateLog.mu.Unlock()
-       io.Copy(os.Stderr, &updateLog.buf)
 }
diff --git a/src/cmd/go/testdata/script/mod_get_update_log.txt b/src/cmd/go/testdata/script/mod_get_update_log.txt
deleted file mode 100644 (file)
index 51f138f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-# Upgrades are reported.
-go get -d rsc.io/quote
-stderr '^go: rsc.io/quote upgrade => v1.5.2\n\z'
-
-# Downgrades are not reported.
-# TODO(golang.org/issue/33284): they should be.
-go get -d rsc.io/quote@v1.5.0
-stderr '^go: downloading.*\n\z'
-
--- go.mod --
-module m
-
-go 1.15
-
-require rsc.io/quote v1.5.0