You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/cmd/go/testdata/script/mod_init_empty.txt
+23
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,22 @@ stdout '^example.com$'
8
8
go list
9
9
stdout '^example.com$'
10
10
11
+
# Reset $GOPATH
12
+
env GOPATH=$WORK/gopath
13
+
14
+
# 'go mod init' should not create a go.mod file in v0 or v1 directory.
15
+
cd $GOPATH/src/example.com/m/v0
16
+
! go mod init
17
+
stderr '(?s)^go: cannot determine module path for source directory(.*)example.com/m/v0 \(bad module path inferred from directory in GOPATH: major version suffixes must be in the form of /vN and are only allowed for v2 or later\)(.*)Example usage:(.*)''go mod init example.com/m'' to initialize a v0 or v1 module(.*)''go mod init example.com/m/v2'' to initialize a v2 module(.*)Run ''go help mod init'' for more information.$'
18
+
19
+
cd $GOPATH/src/example.com/m/v1
20
+
! go mod init
21
+
stderr '(?s)^go: cannot determine module path for source directory(.*)example.com/m/v1 \(bad module path inferred from directory in GOPATH: major version suffixes must be in the form of /vN and are only allowed for v2 or later\)(.*)Example usage:(.*)''go mod init example.com/m'' to initialize a v0 or v1 module(.*)''go mod init example.com/m/v2'' to initialize a v2 module(.*)Run ''go help mod init'' for more information.$'
22
+
23
+
cd $GOPATH/src/example.com/m/v2
24
+
go mod init
25
+
stderr '^go: creating new go.mod: module example.com/m/v2$'
0 commit comments