aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_dot.txt
blob: ca8d5c6cc2d62d9ebd1a64f72efdfaae15d22cf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
env GO111MODULE=on

# golang.org/issue/32917 and golang.org/issue/28459: 'go build' and 'go test'
# in an empty directory should refer to the path '.' and should not attempt
# to resolve an external module.
cd dir
! go get
stderr '^go get: no package in current directory$'
! go get .
stderr '^go get \.: no package in current directory$'
! go get ./subdir
stderr '^go get: \.[/\\]subdir \('$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]subdir\) is not a package in module rooted at '$WORK'[/\\]gopath[/\\]src[/\\]dir$'
! go list
! stderr 'cannot find module providing package'
stderr '^no Go files in '$WORK'[/\\]gopath[/\\]src[/\\]dir$'

cd subdir
! go list
! stderr 'cannot find module providing package'
stderr '^no Go files in '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]subdir$'
cd ..

# golang.org/issue/30590: if a package is found in the filesystem
# but is not in the main module, the error message should not say
# "cannot find module providing package", and we shouldn't try
# to find a module providing the package.
! go list ./othermodule
! stderr 'cannot find module providing package'
stderr '^main module \(example\.com\) does not contain package example.com/othermodule$'

# golang.org/issue/27122: 'go build' of a nonexistent directory should produce
# a helpful "no Go files" error message, not a generic "unknown import path".
! go list ./subdir
stderr '^no Go files in '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]subdir$'

# golang.org/issue/29280: 'go list -e' for a nonexistent directory should
# report a nonexistent package with an error.
go list -e -json ./subdir
stdout '"Incomplete": true'

# golang.org/issue/28155: 'go list ./testdata' should not synthesize underscores.
go list ./testdata
stdout '^example.com/testdata'

# golang.org/issue/32921: vendor directories should only be accepted as directories
# if the directory would actually be used to load the package.
! go list ./vendor/nonexist
stderr '^no Go files in '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]vendor[/\\]nonexist$'

! go list ./vendor/pkg
stderr '^without -mod=vendor, directory '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]vendor[/\\]pkg has no package path$'

! go list -mod=vendor ./vendor/nonexist
stderr '^no Go files in '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]vendor[/\\]nonexist$'

! go list -mod=vendor ./vendor/unlisted
stderr '^directory '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]vendor[/\\]unlisted is not a package listed in vendor/modules.txt$'

go list -mod=vendor ./vendor/pkg
stdout '^pkg$'

# Packages within GOROOT should resolve as in any other module,
# except that -mod=vendor is implied by default.
cd $GOROOT/src
! go list .
stderr '^no Go files in '$GOROOT'[/\\]src$'

! go list ./builtin
stderr '^"builtin" is a pseudo-package, not an importable package$'

! go list ./debug
! stderr 'cannot find module providing package'
stderr '^no Go files in '$GOROOT'[/\\]src[/\\]debug$'

! go list ./golang.org/x/tools/cmd/goimports
! stderr 'cannot find module providing package'
stderr '^stat '$GOROOT'[/\\]src[/\\]golang.org[/\\]x[/\\]tools[/\\]cmd[/\\]goimports: directory not found'

go list ./vendor/golang.org/x/net/http2/hpack
stdout '^golang.org/x/net/http2/hpack$'

# golang.org/issue/30756: packages in other GOROOTs should not get the special
# prefixless treatment of GOROOT itself.
cd $WORK/othergoroot/src
! go list .
stderr '^no Go files in '$WORK'[/\\]othergoroot[/\\]src$'

go list ./builtin
stdout '^std/builtin$'  # Only the "std" in actual $GOROOT is special, and only its "builtin" is special.

! go list ./bytes
! stderr 'cannot find module providing package'
stderr '^no Go files in '$WORK'[/\\]othergoroot[/\\]src[/\\]bytes$'

! go list ./vendor/golang.org/x/net/http2/hpack
stderr '^without -mod=vendor, directory '$WORK'[/\\]othergoroot[/\\]src[/\\]vendor[/\\]golang.org[/\\]x[/\\]net[/\\]http2[/\\]hpack has no package path$'

-- dir/go.mod --
module example.com
go 1.13
-- dir/subdir/README --
There are no Go source files in this directory.
-- dir/othermodule/go.mod --
module example.com/othermodule
go 1.13
-- dir/othermodule/om.go --
package othermodule
-- dir/testdata/td.go --
package testdata
-- dir/vendor/modules.txt --
# pkg v0.0.0
pkg
-- dir/vendor/nonexist/README --
There are no Go source files here either.
-- dir/vendor/pkg/pkg.go --
package pkg
-- dir/vendor/unlisted/unlisted.go --
package unlisted
-- emptyroot/go.mod --
module example.com/emptyroot
-- emptyroot/pkg/pkg.go --
package pkg
-- $WORK/othergoroot/src/go.mod --
module std
go 1.13
-- $WORK/othergoroot/src/builtin/builtin.go --
package builtin
-- $WORK/othergoroot/src/bytes/README --
There are no Go source files in this directory.
-- $WORK/othergoroot/src/vendor/golang.org/x/net/http2/hpack --
package hpack