1
0
mirror of https://github.com/golang/go synced 2024-09-30 11:18:33 -06:00

Revert "cmd/go: group 'go get' update messages together near the end of output"

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>
This commit is contained in:
Austin Clements 2020-05-30 20:40:58 +00:00
parent 1ed57c1b72
commit fc40beb987
2 changed files with 3 additions and 43 deletions

View File

@ -6,10 +6,8 @@
package modget package modget
import ( import (
"bytes"
"errors" "errors"
"fmt" "fmt"
"io"
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
@ -704,12 +702,6 @@ func runGet(cmd *base.Command, args []string) {
modload.AllowWriteGoMod() modload.AllowWriteGoMod()
modload.WriteGoMod() 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. // If -d was specified, we're done after the module work.
// We've already downloaded modules by loading packages above. // We've already downloaded modules by loading packages above.
// Otherwise, we need to build and install the packages matched by // 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) return r.Reqs.Required(mod)
} }
var updateLog struct { var loggedLines sync.Map
mu sync.Mutex
buf bytes.Buffer
logged map[string]bool
}
func logOncef(format string, args ...interface{}) { func logOncef(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...) msg := fmt.Sprintf(format, args...)
updateLog.mu.Lock() if _, dup := loggedLines.LoadOrStore(msg, true); !dup {
defer updateLog.mu.Unlock() fmt.Fprintln(os.Stderr, msg)
if updateLog.logged == nil {
updateLog.logged = make(map[string]bool)
} }
if updateLog.logged[msg] {
return
}
updateLog.logged[msg] = true
fmt.Fprintln(&updateLog.buf, msg)
}
func writeUpdateLog() {
updateLog.mu.Lock()
defer updateLog.mu.Unlock()
io.Copy(os.Stderr, &updateLog.buf)
} }

View File

@ -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