1
0
mirror of https://github.com/golang/go synced 2024-09-23 17:20:13 -06:00

Error if -insecure is provided to go get

This commit is contained in:
witchard 2021-03-02 21:08:39 +00:00
parent 37c56a8b7b
commit aa018af6f8
3 changed files with 32 additions and 11 deletions

View File

@ -98,11 +98,12 @@ Usage: ` + CmdGet.UsageLine + `
}
var (
getD = CmdGet.Flag.Bool("d", false, "")
getF = CmdGet.Flag.Bool("f", false, "")
getT = CmdGet.Flag.Bool("t", false, "")
getU = CmdGet.Flag.Bool("u", false, "")
getFix = CmdGet.Flag.Bool("fix", false, "")
getD = CmdGet.Flag.Bool("d", false, "")
getF = CmdGet.Flag.Bool("f", false, "")
getT = CmdGet.Flag.Bool("t", false, "")
getU = CmdGet.Flag.Bool("u", false, "")
getFix = CmdGet.Flag.Bool("fix", false, "")
getInsecure = CmdGet.Flag.Bool("insecure", false, "")
)
func init() {
@ -121,6 +122,9 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
if *getF && !*getU {
base.Fatalf("go get: cannot use -f flag without -u")
}
if *getInsecure {
base.Fatalf("go get: -insecure flag is no longer supported; use GOINSECURE instead")
}
// Disable any prompting for passwords by Git.
// Only has an effect for 2.3.0 or later, but avoiding

View File

@ -218,12 +218,13 @@ variable for future go command invocations.
}
var (
getD = CmdGet.Flag.Bool("d", false, "")
getF = CmdGet.Flag.Bool("f", false, "")
getFix = CmdGet.Flag.Bool("fix", false, "")
getM = CmdGet.Flag.Bool("m", false, "")
getT = CmdGet.Flag.Bool("t", false, "")
getU upgradeFlag
getD = CmdGet.Flag.Bool("d", false, "")
getF = CmdGet.Flag.Bool("f", false, "")
getFix = CmdGet.Flag.Bool("fix", false, "")
getM = CmdGet.Flag.Bool("m", false, "")
getT = CmdGet.Flag.Bool("t", false, "")
getU upgradeFlag
getInsecure = CmdGet.Flag.Bool("insecure", false, "")
// -v is cfg.BuildV
)
@ -273,6 +274,9 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
if *getM {
base.Fatalf("go get: -m flag is no longer supported; consider -d to skip building packages")
}
if *getInsecure {
base.Fatalf("go get: -insecure flag is no longer supported; use GOINSECURE instead")
}
load.ModResolveTests = *getT
// Do not allow any updating of go.mod until we've applied

View File

@ -0,0 +1,13 @@
# GOPATH: Set up
env GO111MODULE=off
# GOPATH: Fetch with insecure, should error
! go get -insecure test
stderr 'go get: -insecure flag is no longer supported; use GOINSECURE instead'
# Modules: Set up
env GO111MODULE=on
# Modules: Fetch with insecure, should error
! go get -insecure test
stderr 'go get: -insecure flag is no longer supported; use GOINSECURE instead'