File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 5
5
package modcmd
6
6
7
7
import (
8
+ "cmd/go/internal/cfg"
8
9
"encoding/json"
9
10
"os"
10
11
@@ -67,6 +68,13 @@ type moduleJSON struct {
67
68
}
68
69
69
70
func runDownload (cmd * base.Command , args []string ) {
71
+ // Check whether modules are enabled and whether we're in a module.
72
+ if cfg .Getenv ("GO111MODULE" ) == "off" {
73
+ base .Fatalf ("go: modules disabled by GO111MODULE=off; see 'go help modules'" )
74
+ }
75
+ if ! modload .HasModRoot () && len (args ) == 0 {
76
+ base .Fatalf ("go mod download: no modules specified (see 'go help mod download')" )
77
+ }
70
78
if len (args ) == 0 {
71
79
args = []string {"all" }
72
80
}
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ stderr 'go mod init: modules disabled by GO111MODULE=off; see ''go help modules'
9
9
stderr 'go: modules disabled by GO111MODULE=off; see ''go help modules'''
10
10
! go mod verify
11
11
stderr 'go: modules disabled by GO111MODULE=off; see ''go help modules'''
12
+ ! go mod download
13
+ stderr 'go: modules disabled by GO111MODULE=off; see ''go help modules'''
12
14
13
15
# Same result in an empty directory
14
16
mkdir z
@@ -19,6 +21,8 @@ stderr 'go mod init: modules disabled by GO111MODULE=off; see ''go help modules'
19
21
stderr 'go: modules disabled by GO111MODULE=off; see ''go help modules'''
20
22
! go mod verify
21
23
stderr 'go: modules disabled by GO111MODULE=off; see ''go help modules'''
24
+ ! go mod download
25
+ stderr 'go: modules disabled by GO111MODULE=off; see ''go help modules'''
22
26
23
27
-- sample.go --
24
28
package sample
You can’t perform that action at this time.
0 commit comments