@@ -43,7 +43,10 @@ The -fix flag instructs get to run the fix tool on the downloaded packages
43
43
before resolving dependencies or building the code.
44
44
45
45
The -insecure flag permits fetching from repositories and resolving
46
- custom domains using insecure schemes such as HTTP. Use with caution.
46
+ custom domains using insecure schemes such as HTTP. Use with caution. The
47
+ GOINSECURE environment variable is usually a better alternative, since it
48
+ provides control over which modules may be retrieved using an insecure scheme.
49
+ See 'go help environment' for details.
47
50
48
51
The -t flag instructs get to also download the packages required to build
49
52
the tests for the specified packages.
@@ -411,11 +414,6 @@ func downloadPackage(p *load.Package) error {
411
414
blindRepo bool // set if the repo has unusual configuration
412
415
)
413
416
414
- security := web .SecureOnly
415
- if Insecure {
416
- security = web .Insecure
417
- }
418
-
419
417
// p can be either a real package, or a pseudo-package whose “import path” is
420
418
// actually a wildcard pattern.
421
419
// Trim the path at the element containing the first wildcard,
@@ -432,6 +430,10 @@ func downloadPackage(p *load.Package) error {
432
430
if err := module .CheckImportPath (importPrefix ); err != nil {
433
431
return fmt .Errorf ("%s: invalid import path: %v" , p .ImportPath , err )
434
432
}
433
+ security := web .SecureOnly
434
+ if Insecure || module .MatchPrefixPatterns (cfg .GOINSECURE , importPrefix ) {
435
+ security = web .Insecure
436
+ }
435
437
436
438
if p .Internal .Build .SrcRoot != "" {
437
439
// Directory exists. Look for checkout along path to src.
@@ -475,7 +477,7 @@ func downloadPackage(p *load.Package) error {
475
477
}
476
478
vcs , repo , rootPath = rr .vcs , rr .Repo , rr .Root
477
479
}
478
- if ! blindRepo && ! vcs .isSecure (repo ) && ! Insecure {
480
+ if ! blindRepo && ! vcs .isSecure (repo ) && security != web . Insecure {
479
481
return fmt .Errorf ("cannot download, %v uses insecure protocol" , repo )
480
482
}
481
483
0 commit comments