Moved module env var check to modcmd from modinit

This commit is contained in:
Rens Rikkerink 2019-04-09 15:49:34 +02:00
parent 226e846627
commit ada1aba2cb
No known key found for this signature in database
GPG Key ID: 3EDE6BE920496401
2 changed files with 5 additions and 1 deletions

View File

@ -35,6 +35,9 @@ func runInit(cmd *base.Command, args []string) {
if len(args) == 1 {
modload.CmdModModule = args[0]
}
if os.Getenv("GO111MODULE") == "off" {
base.Fatalf("go mod init: modules disabled by GO111MODULE=off; see 'go help modules'")
}
if _, err := os.Stat("go.mod"); err == nil {
base.Fatalf("go mod init: go.mod already exists")
}

View File

@ -99,7 +99,8 @@ func Init() {
case "on", "":
mustUseModules = true
case "off":
die()
mustUseModules = false
return
}
// Disable any prompting for passwords by Git.