]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: move get.Insecure to cfg.Insecure to break dependency cycle
authorJay Conrod <jayconrod@google.com>
Wed, 2 Sep 2020 17:25:11 +0000 (13:25 -0400)
committerJay Conrod <jayconrod@google.com>
Fri, 11 Sep 2020 18:14:42 +0000 (18:14 +0000)
Change-Id: If9c73ff5adc7e080a48ecc6b35ce40822193d66f
Reviewed-on: https://go-review.googlesource.com/c/go/+/254363
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/internal/cfg/cfg.go
src/cmd/go/internal/get/get.go
src/cmd/go/internal/modfetch/insecure.go
src/cmd/go/internal/modfetch/sumdb.go
src/cmd/go/internal/modget/get.go

index f874b880a6daee9ee6c43b63f4e48b5e50c523db..9bf1db73ef680469468b0254f8e9641e6e7902d0 100644 (file)
@@ -49,6 +49,8 @@ var (
        ModCacheRW bool   // -modcacherw flag
        ModFile    string // -modfile flag
 
+       Insecure bool // -insecure flag
+
        CmdName string // "build", "install", "list", "mod tidy", etc.
 
        DebugActiongraph string // -debug-actiongraph flag (undocumented, unstable)
index d0be3fe1e7078fe469e062d8b08c4cbbfce758e1..9e4825eb3796cb1aedd77557fb5f9ef002e3772d 100644 (file)
@@ -108,14 +108,12 @@ var (
        getT   = CmdGet.Flag.Bool("t", false, "")
        getU   = CmdGet.Flag.Bool("u", false, "")
        getFix = CmdGet.Flag.Bool("fix", false, "")
-
-       Insecure bool
 )
 
 func init() {
        work.AddBuildFlags(CmdGet, work.OmitModFlag|work.OmitModCommonFlags)
        CmdGet.Run = runGet // break init loop
-       CmdGet.Flag.BoolVar(&Insecure, "insecure", Insecure, "")
+       CmdGet.Flag.BoolVar(&cfg.Insecure, "insecure", cfg.Insecure, "")
 }
 
 func runGet(ctx context.Context, cmd *base.Command, args []string) {
@@ -431,7 +429,7 @@ func downloadPackage(p *load.Package) error {
                return fmt.Errorf("%s: invalid import path: %v", p.ImportPath, err)
        }
        security := web.SecureOnly
-       if Insecure || module.MatchPrefixPatterns(cfg.GOINSECURE, importPrefix) {
+       if cfg.Insecure || module.MatchPrefixPatterns(cfg.GOINSECURE, importPrefix) {
                security = web.Insecure
        }
 
index b692669cbabae76b4b195af7f419523527856929..012d05f29db55cd36060296eea832c58d7b149fc 100644 (file)
@@ -6,12 +6,11 @@ package modfetch
 
 import (
        "cmd/go/internal/cfg"
-       "cmd/go/internal/get"
 
        "golang.org/x/mod/module"
 )
 
 // allowInsecure reports whether we are allowed to fetch this path in an insecure manner.
 func allowInsecure(path string) bool {
-       return get.Insecure || module.MatchPrefixPatterns(cfg.GOINSECURE, path)
+       return cfg.Insecure || module.MatchPrefixPatterns(cfg.GOINSECURE, path)
 }
index 783c4a433b41c6b00faf7539e26d136f353827f6..47a257153146b153b21fe738744c79c1f2416fa9 100644 (file)
@@ -22,7 +22,6 @@ import (
 
        "cmd/go/internal/base"
        "cmd/go/internal/cfg"
-       "cmd/go/internal/get"
        "cmd/go/internal/lockedfile"
        "cmd/go/internal/web"
 
@@ -33,7 +32,7 @@ import (
 
 // useSumDB reports whether to use the Go checksum database for the given module.
 func useSumDB(mod module.Version) bool {
-       return cfg.GOSUMDB != "off" && !get.Insecure && !module.MatchPrefixPatterns(cfg.GONOSUMDB, mod.Path)
+       return cfg.GOSUMDB != "off" && !cfg.Insecure && !module.MatchPrefixPatterns(cfg.GONOSUMDB, mod.Path)
 }
 
 // lookupSumDB returns the Go checksum database's go.sum lines for the given module,
index a2a8287d84658e46f515c2f98a94309b93a3705b..829cfe055ada9fe0b25f5c5dc93857c1f0061fcf 100644 (file)
@@ -17,7 +17,7 @@ import (
        "sync"
 
        "cmd/go/internal/base"
-       "cmd/go/internal/get"
+       "cmd/go/internal/cfg"
        "cmd/go/internal/imports"
        "cmd/go/internal/load"
        "cmd/go/internal/modload"
@@ -181,7 +181,7 @@ var (
        getM   = CmdGet.Flag.Bool("m", false, "")
        getT   = CmdGet.Flag.Bool("t", false, "")
        getU   upgradeFlag
-       // -insecure is get.Insecure
+       // -insecure is cfg.Insecure
        // -v is cfg.BuildV
 )
 
@@ -206,7 +206,7 @@ func (v *upgradeFlag) String() string { return "" }
 func init() {
        work.AddBuildFlags(CmdGet, work.OmitModFlag)
        CmdGet.Run = runGet // break init loop
-       CmdGet.Flag.BoolVar(&get.Insecure, "insecure", get.Insecure, "")
+       CmdGet.Flag.BoolVar(&cfg.Insecure, "insecure", cfg.Insecure, "")
        CmdGet.Flag.Var(&getU, "u", "")
 }