]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: use verbose flag to log proxy activities
authorConstantin Konstantinidis <constantinkonstantinidis@gmail.com>
Sun, 12 Apr 2020 19:28:41 +0000 (21:28 +0200)
committerJay Conrod <jayconrod@google.com>
Mon, 24 Aug 2020 13:59:40 +0000 (13:59 +0000)
Fixes #29515
Fixes #30604

Change-Id: Ie75a331cd6ca51806c5720443506d4fe0bec28cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/227162
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/proxy_test.go
src/cmd/go/testdata/script/mod_download.txt
src/cmd/go/testdata/script/mod_download_json.txt
src/cmd/go/testdata/script/mod_get_commit.txt
src/cmd/go/testdata/script/mod_get_moved.txt
src/cmd/go/testdata/script/mod_query_exclude.txt

index 7f58fb8ce43f4dbd0c17909706cb0cef0a2b7615..42972f5b2a1ceecc7d2495300a9f5c1b2acd9642 100644 (file)
@@ -91,7 +91,7 @@ func readModList() {
                encPath := strings.ReplaceAll(name[:i], "_", "/")
                path, err := module.UnescapePath(encPath)
                if err != nil {
-                       if encPath != "example.com/invalidpath/v1" {
+                       if testing.Verbose() && encPath != "example.com/invalidpath/v1" {
                                fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
                        }
                        continue
@@ -137,13 +137,6 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
                return
        }
 
-       // /mod/quiet/ does not print errors.
-       quiet := false
-       if strings.HasPrefix(path, "quiet/") {
-               path = path[len("quiet/"):]
-               quiet = true
-       }
-
        // Next element may opt into special behavior.
        if j := strings.Index(path, "/"); j >= 0 {
                n, err := strconv.Atoi(path[:j])
@@ -220,7 +213,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
                enc := path[:i]
                modPath, err := module.UnescapePath(enc)
                if err != nil {
-                       if !quiet {
+                       if testing.Verbose() {
                                fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
                        }
                        http.NotFound(w, r)
@@ -273,7 +266,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
        enc, file := path[:i], path[i+len("/@v/"):]
        path, err := module.UnescapePath(enc)
        if err != nil {
-               if !quiet {
+               if testing.Verbose() {
                        fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
                }
                http.NotFound(w, r)
@@ -339,7 +332,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
 
        a, err := readArchive(path, vers)
        if err != nil {
-               if !quiet {
+               if testing.Verbose() {
                        fmt.Fprintf(os.Stderr, "go proxy: no archive %s %s: %v\n", path, vers, err)
                }
                if errors.Is(err, os.ErrNotExist) {
@@ -393,7 +386,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
                }).(cached)
 
                if c.err != nil {
-                       if !quiet {
+                       if testing.Verbose() {
                                fmt.Fprintf(os.Stderr, "go proxy: %v\n", c.err)
                        }
                        http.Error(w, c.err.Error(), 500)
index 3573928a9338d7484b3dc71f173181c14b50c1d9..bb5c4627db697668697587344fecf743c5b74467 100644 (file)
@@ -1,5 +1,4 @@
 env GO111MODULE=on
-env GOPROXY=$GOPROXY/quiet
 
 # download with version should print nothing
 go mod download rsc.io/quote@v1.5.0
index 01c35dd993759c8e34cfe4b97c831f389ce1145a..26291681ce87feeeb3aa371ff976fbbbaeebc20f 100644 (file)
@@ -1,5 +1,4 @@
 env GO111MODULE=on
-env GOPROXY=$GOPROXY/quiet
 env GOSUMDB=$sumdb' '$proxy/sumdb-wrong
 
 # download -json with version should print JSON on sumdb failure
index d108242c70e227b30b4d187dc4f7606ec820398a..857740ae6cb12d1410f6d7d1a4fa7cf89cdbc5ef 100644 (file)
@@ -1,5 +1,4 @@
 env GO111MODULE=on
-env GOPROXY=$GOPROXY/quiet
 [short] skip
 
 # @commit should resolve
index edc41cf9488a26f4d53f86c13d79a4e1d4b43fd2..b46ec8e8b6f2e636ae6013560cb5bbb6570157f3 100644 (file)
@@ -1,5 +1,4 @@
 env GO111MODULE=on
-env GOPROXY=$GOPROXY/quiet
 [short] skip
 
 # A 'go get' that worked at a previous version should continue to work at that version,
index 1ae0d17844a8f662cf53ae5225216d70baa4de7b..a64a8e10866a46989e32b8d371e696afc92f0215 100644 (file)
@@ -1,5 +1,4 @@
 env GO111MODULE=on
-env GOPROXY=$GOPROXY/quiet
 
 # get excluded version
 cp go.mod1 go.mod