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_outside.txt
+26-26Lines changed: 26 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -12,13 +12,13 @@ stdout 'NUL|/dev/null'
12
12
# 'go list' without arguments implicitly operates on the current directory,
13
13
# which is not in a module.
14
14
! go list
15
-
stderr 'cannot find main module'
15
+
stderr '^go: go.mod file not found in current directory or any parent directory; see ''go help modules''$'
16
16
go list -m
17
17
stdout '^command-line-arguments$'
18
18
# 'go list' in the working directory should fail even if there is a a 'package
19
19
# main' present: without a main module, we do not know its package path.
20
20
! go list ./needmod
21
-
stderr 'cannot find main module'
21
+
stderr '^go: go.mod file not found in current directory or any parent directory; see ''go help modules''$'
22
22
23
23
# 'go list all' lists the transitive import graph of the main module,
24
24
# which is empty if there is no main module.
@@ -41,7 +41,7 @@ stdout 'command-line-arguments'
41
41
42
42
# 'go list' on a package from a module should fail.
43
43
! go list example.com/printversion
44
-
stderr '^no required module provides package example.com/printversion: working directory is not part of a module$'
44
+
stderr '^no required module provides package example.com/printversion: go.mod file not found in current directory or any parent directory; see ''go help modules''$'
45
45
46
46
47
47
# 'go list -m' with an explicit version should resolve that version.
# 'go build' without arguments implicitly operates on the current directory, and should fail.
148
148
cd needmod
149
149
! go build
150
-
stderr 'cannot find main module'
150
+
stderr '^go: go.mod file not found in current directory or any parent directory; see ''go help modules''$'
151
151
cd ..
152
152
153
153
# 'go build' of a non-module directory should fail too.
154
154
! go build ./needmod
155
-
stderr 'cannot find main module'
155
+
stderr '^go: go.mod file not found in current directory or any parent directory; see ''go help modules''$'
156
156
157
157
# 'go build' of source files should fail if they import anything outside std.
158
158
! go build -n ./needmod/needmod.go
159
-
stderr '^needmod[/\\]needmod.go:10:2: no required module provides package example.com/version: working directory is not part of a module$'
159
+
stderr '^needmod[/\\]needmod.go:10:2: no required module provides package example.com/version: go.mod file not found in current directory or any parent directory; see ''go help modules''$'
160
160
161
161
# 'go build' of source files should succeed if they do not import anything outside std.
162
162
go build -n -o ignore ./stdonly/stdonly.go
@@ -179,7 +179,7 @@ go doc fmt
179
179
180
180
# 'go doc' should fail for a package path outside a module.
181
181
! go doc example.com/version
182
-
stderr 'doc: no required module provides package example.com/version: working directory is not part of a module'
182
+
stderr 'doc: no required module provides package example.com/version: go.mod file not found in current directory or any parent directory; see ''go help modules''$'
183
183
184
184
# 'go install' with a version should succeed if all constraints are met.
185
185
# See mod_install_pkg_version.
@@ -194,7 +194,7 @@ stderr '^go install: version is required when current directory is not in a modu
194
194
# 'go install' should fail if a source file imports a package that must be
195
195
# resolved to a module.
196
196
! go install ./needmod/needmod.go
197
-
stderr 'needmod[/\\]needmod.go:10:2: no required module provides package example.com/version: working directory is not part of a module'
197
+
stderr 'needmod[/\\]needmod.go:10:2: no required module provides package example.com/version: go.mod file not found in current directory or any parent directory; see ''go help modules''$'
198
198
199
199
# 'go install' should succeed with a package in GOROOT.
200
200
go install cmd/addr2line
@@ -206,12 +206,12 @@ stderr 'can only use path@version syntax with'
206
206
207
207
# 'go run' should fail if a package argument must be resolved to a module.
208
208
! go run example.com/printversion
209
-
stderr '^no required module provides package example.com/printversion: working directory is not part of a module$'
209
+
stderr '^no required module provides package example.com/printversion: go.mod file not found in current directory or any parent directory; see ''go help modules''$'
210
210
211
211
# 'go run' should fail if a source file imports a package that must be
212
212
# resolved to a module.
213
213
! go run ./needmod/needmod.go
214
-
stderr '^needmod[/\\]needmod.go:10:2: no required module provides package example.com/version: working directory is not part of a module$'
214
+
stderr '^needmod[/\\]needmod.go:10:2: no required module provides package example.com/version: go.mod file not found in current directory or any parent directory; see ''go help modules''$'
215
215
216
216
217
217
# 'go fmt' should be able to format files outside of a module.
0 commit comments