aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2019-08-21 10:43:49 -0400
committerRuss Cox <rsc@golang.org>2019-08-21 15:13:03 +0000
commitc61c29fe563134f752ea14e794d08031982145e8 (patch)
tree3c9533a423209ad2bc331950dcddae0721e79f8a
parent723852388eed2b023c7a47219ebebf722b3a7ced (diff)
downloadgo-c61c29fe563134f752ea14e794d08031982145e8.tar.gz
go-c61c29fe563134f752ea14e794d08031982145e8.zip
cmd/go: accept GOSUMDB=sum.golang.google.cn
This CL makes the go command understand that GOSUMDB=sum.golang.google.cn should connect to that domain but expect to find a checksum database signed by sum.golang.org there. The host sum.golang.google.cn is not yet completely configured; we hope it will be available in a few weeks. Change-Id: Ie0fc4323f0c7084dda59bd3b45fc406717fa16d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/191137 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org>
-rw-r--r--src/cmd/go/alldocs.go8
-rw-r--r--src/cmd/go/internal/modfetch/fetch.go8
-rw-r--r--src/cmd/go/internal/modfetch/sumdb.go12
3 files changed, 21 insertions, 7 deletions
diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go
index 63ec2321be..ebbead5d31 100644
--- a/src/cmd/go/alldocs.go
+++ b/src/cmd/go/alldocs.go
@@ -2743,9 +2743,11 @@
// GOSUMDB="sum.golang.org+<publickey>"
// GOSUMDB="sum.golang.org+<publickey> https://sum.golang.org"
//
-// The go command knows the public key of sum.golang.org; use of any other
-// database requires giving the public key explicitly. The URL defaults to
-// "https://" followed by the database name.
+// The go command knows the public key of sum.golang.org, and also that the name
+// sum.golang.google.cn (available inside mainland China) connects to the
+// sum.golang.org checksum database; use of any other database requires giving
+// the public key explicitly.
+// The URL defaults to "https://" followed by the database name.
//
// GOSUMDB defaults to "sum.golang.org", the Go checksum database run by Google.
// See https://sum.golang.org/privacy for the service's privacy policy.
diff --git a/src/cmd/go/internal/modfetch/fetch.go b/src/cmd/go/internal/modfetch/fetch.go
index 74e36cc6fc..51a56028c4 100644
--- a/src/cmd/go/internal/modfetch/fetch.go
+++ b/src/cmd/go/internal/modfetch/fetch.go
@@ -701,9 +701,11 @@ to use and optionally its public key and URL, as in:
GOSUMDB="sum.golang.org+<publickey>"
GOSUMDB="sum.golang.org+<publickey> https://sum.golang.org"
-The go command knows the public key of sum.golang.org; use of any other
-database requires giving the public key explicitly. The URL defaults to
-"https://" followed by the database name.
+The go command knows the public key of sum.golang.org, and also that the name
+sum.golang.google.cn (available inside mainland China) connects to the
+sum.golang.org checksum database; use of any other database requires giving
+the public key explicitly.
+The URL defaults to "https://" followed by the database name.
GOSUMDB defaults to "sum.golang.org", the Go checksum database run by Google.
See https://sum.golang.org/privacy for the service's privacy policy.
diff --git a/src/cmd/go/internal/modfetch/sumdb.go b/src/cmd/go/internal/modfetch/sumdb.go
index b0bb3d4d5e..1c24ec273b 100644
--- a/src/cmd/go/internal/modfetch/sumdb.go
+++ b/src/cmd/go/internal/modfetch/sumdb.go
@@ -60,7 +60,17 @@ func dbDial() (dbName string, db *sumweb.Conn, err error) {
// $GOSUMDB can be "key" or "key url",
// and the key can be a full verifier key
// or a host on our list of known keys.
- key := strings.Fields(cfg.GOSUMDB)
+
+ // Special case: sum.golang.google.cn
+ // is an alias, reachable inside mainland China,
+ // for sum.golang.org. If there are more
+ // of these we should add a map like knownGOSUMDB.
+ gosumdb := cfg.GOSUMDB
+ if gosumdb == "sum.golang.google.cn" {
+ gosumdb = "sum.golang.org https://sum.golang.google.cn"
+ }
+
+ key := strings.Fields(gosumdb)
if len(key) >= 1 {
if k := knownGOSUMDB[key[0]]; k != "" {
key[0] = k