Skip to content

Commit 86ee84c

Browse files
author
Jay Conrod
committed
cmd/go: move get.Insecure to cfg.Insecure to break dependency cycle
Change-Id: If9c73ff5adc7e080a48ecc6b35ce40822193d66f Reviewed-on: https://go-review.googlesource.com/c/go/+/254363 Run-TryBot: Jay Conrod <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> Reviewed-by: Michael Matloob <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent b459bc8 commit 86ee84c

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

src/cmd/go/internal/cfg/cfg.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ var (
4949
ModCacheRW bool // -modcacherw flag
5050
ModFile string // -modfile flag
5151

52+
Insecure bool // -insecure flag
53+
5254
CmdName string // "build", "install", "list", "mod tidy", etc.
5355

5456
DebugActiongraph string // -debug-actiongraph flag (undocumented, unstable)

src/cmd/go/internal/get/get.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,12 @@ var (
108108
getT = CmdGet.Flag.Bool("t", false, "")
109109
getU = CmdGet.Flag.Bool("u", false, "")
110110
getFix = CmdGet.Flag.Bool("fix", false, "")
111-
112-
Insecure bool
113111
)
114112

115113
func init() {
116114
work.AddBuildFlags(CmdGet, work.OmitModFlag|work.OmitModCommonFlags)
117115
CmdGet.Run = runGet // break init loop
118-
CmdGet.Flag.BoolVar(&Insecure, "insecure", Insecure, "")
116+
CmdGet.Flag.BoolVar(&cfg.Insecure, "insecure", cfg.Insecure, "")
119117
}
120118

121119
func runGet(ctx context.Context, cmd *base.Command, args []string) {
@@ -431,7 +429,7 @@ func downloadPackage(p *load.Package) error {
431429
return fmt.Errorf("%s: invalid import path: %v", p.ImportPath, err)
432430
}
433431
security := web.SecureOnly
434-
if Insecure || module.MatchPrefixPatterns(cfg.GOINSECURE, importPrefix) {
432+
if cfg.Insecure || module.MatchPrefixPatterns(cfg.GOINSECURE, importPrefix) {
435433
security = web.Insecure
436434
}
437435

src/cmd/go/internal/modfetch/insecure.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ package modfetch
66

77
import (
88
"cmd/go/internal/cfg"
9-
"cmd/go/internal/get"
109

1110
"golang.org/x/mod/module"
1211
)
1312

1413
// allowInsecure reports whether we are allowed to fetch this path in an insecure manner.
1514
func allowInsecure(path string) bool {
16-
return get.Insecure || module.MatchPrefixPatterns(cfg.GOINSECURE, path)
15+
return cfg.Insecure || module.MatchPrefixPatterns(cfg.GOINSECURE, path)
1716
}

src/cmd/go/internal/modfetch/sumdb.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
"cmd/go/internal/base"
2424
"cmd/go/internal/cfg"
25-
"cmd/go/internal/get"
2625
"cmd/go/internal/lockedfile"
2726
"cmd/go/internal/web"
2827

@@ -33,7 +32,7 @@ import (
3332

3433
// useSumDB reports whether to use the Go checksum database for the given module.
3534
func useSumDB(mod module.Version) bool {
36-
return cfg.GOSUMDB != "off" && !get.Insecure && !module.MatchPrefixPatterns(cfg.GONOSUMDB, mod.Path)
35+
return cfg.GOSUMDB != "off" && !cfg.Insecure && !module.MatchPrefixPatterns(cfg.GONOSUMDB, mod.Path)
3736
}
3837

3938
// lookupSumDB returns the Go checksum database's go.sum lines for the given module,

src/cmd/go/internal/modget/get.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"sync"
1818

1919
"cmd/go/internal/base"
20-
"cmd/go/internal/get"
20+
"cmd/go/internal/cfg"
2121
"cmd/go/internal/imports"
2222
"cmd/go/internal/load"
2323
"cmd/go/internal/modload"
@@ -181,7 +181,7 @@ var (
181181
getM = CmdGet.Flag.Bool("m", false, "")
182182
getT = CmdGet.Flag.Bool("t", false, "")
183183
getU upgradeFlag
184-
// -insecure is get.Insecure
184+
// -insecure is cfg.Insecure
185185
// -v is cfg.BuildV
186186
)
187187

@@ -206,7 +206,7 @@ func (v *upgradeFlag) String() string { return "" }
206206
func init() {
207207
work.AddBuildFlags(CmdGet, work.OmitModFlag)
208208
CmdGet.Run = runGet // break init loop
209-
CmdGet.Flag.BoolVar(&get.Insecure, "insecure", get.Insecure, "")
209+
CmdGet.Flag.BoolVar(&cfg.Insecure, "insecure", cfg.Insecure, "")
210210
CmdGet.Flag.Var(&getU, "u", "")
211211
}
212212

0 commit comments

Comments
 (0)