| 1 |
env GOWORK=off |
| 2 |
env GO111MODULE=on |
| 3 |
|
| 4 |
# golang.org/issue/32917 and golang.org/issue/28459: 'go build' and 'go test' |
| 5 |
# in an empty directory should refer to the path '.' and should not attempt |
| 6 |
# to resolve an external module. |
| 7 |
cd dir |
| 8 |
! go get |
| 9 |
stderr '^go: no package to get in current directory$' |
| 10 |
! go get . |
| 11 |
stderr '^go: .: no package to get in current directory$' |
| 12 |
! go get ./subdir |
| 13 |
stderr '^go: \.[/\\]subdir \('$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]subdir\) is not a package in module rooted at '$WORK'[/\\]gopath[/\\]src[/\\]dir$' |
| 14 |
! go list |
| 15 |
! stderr 'cannot find module providing package' |
| 16 |
stderr '^no Go files in '$WORK'[/\\]gopath[/\\]src[/\\]dir$' |
| 17 |
|
| 18 |
cd subdir |
| 19 |
! go list |
| 20 |
! stderr 'cannot find module providing package' |
| 21 |
stderr '^no Go files in '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]subdir$' |
| 22 |
cd .. |
| 23 |
|
| 24 |
# golang.org/issue/30590: if a package is found in the filesystem |
| 25 |
# but is not in the main module, the error message should not say |
| 26 |
# "cannot find module providing package", and we shouldn't try |
| 27 |
# to find a module providing the package. |
| 28 |
! go list ./othermodule |
| 29 |
! stderr 'cannot find module providing package' |
| 30 |
stderr '^main module \(example\.com\) does not contain package example.com/othermodule$' |
| 31 |
|
| 32 |
# golang.org/issue/27122: 'go build' of a nonexistent directory should produce |
| 33 |
# a helpful "no Go files" error message, not a generic "unknown import path". |
| 34 |
! go list ./subdir |
| 35 |
stderr '^no Go files in '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]subdir$' |
| 36 |
|
| 37 |
# golang.org/issue/29280: 'go list -e' for a nonexistent directory should |
| 38 |
# report a nonexistent package with an error. |
| 39 |
go list -e -json ./subdir |
| 40 |
stdout '"Incomplete": true' |
| 41 |
|
| 42 |
# golang.org/issue/28155: 'go list ./testdata' should not synthesize underscores. |
| 43 |
go list ./testdata |
| 44 |
stdout '^example.com/testdata' |
| 45 |
|
| 46 |
# golang.org/issue/32921: vendor directories should only be accepted as directories |
| 47 |
# if the directory would actually be used to load the package. |
| 48 |
! go list ./vendor/nonexist |
| 49 |
stderr '^no Go files in '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]vendor[/\\]nonexist$' |
| 50 |
|
| 51 |
! go list ./vendor/pkg |
| 52 |
stderr '^without -mod=vendor, directory '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]vendor[/\\]pkg has no package path$' |
| 53 |
|
| 54 |
! go list -mod=vendor ./vendor/nonexist |
| 55 |
stderr '^no Go files in '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]vendor[/\\]nonexist$' |
| 56 |
|
| 57 |
! go list -mod=vendor ./vendor/unlisted |
| 58 |
stderr '^directory '$WORK'[/\\]gopath[/\\]src[/\\]dir[/\\]vendor[/\\]unlisted is not a package listed in vendor/modules.txt$' |
| 59 |
|
| 60 |
go list -mod=vendor ./vendor/pkg |
| 61 |
stdout '^pkg$' |
| 62 |
|
| 63 |
# Packages within GOROOT should resolve as in any other module, |
| 64 |
# except that -mod=vendor is implied by default. |
| 65 |
cd $GOROOT/src |
| 66 |
! go list . |
| 67 |
stderr '^no Go files in '$GOROOT'[/\\]src$' |
| 68 |
|
| 69 |
! go list ./builtin |
| 70 |
stderr '^"builtin" is a pseudo-package, not an importable package$' |
| 71 |
|
| 72 |
! go list ./debug |
| 73 |
! stderr 'cannot find module providing package' |
| 74 |
stderr '^no Go files in '$GOROOT'[/\\]src[/\\]debug$' |
| 75 |
|
| 76 |
! go list ./golang.org/x/tools/cmd/goimports |
| 77 |
! stderr 'cannot find module providing package' |
| 78 |
stderr '^stat '$GOROOT'[/\\]src[/\\]golang.org[/\\]x[/\\]tools[/\\]cmd[/\\]goimports: directory not found' |
| 79 |
|
| 80 |
go list ./vendor/golang.org/x/net/http2/hpack |
| 81 |
stdout '^golang.org/x/net/http2/hpack$' |
| 82 |
|
| 83 |
# golang.org/issue/30756: packages in other GOROOTs should not get the special |
| 84 |
# prefixless treatment of GOROOT itself. |
| 85 |
cd $WORK/othergoroot/src |
| 86 |
! go list . |
| 87 |
stderr '^no Go files in '$WORK'[/\\]othergoroot[/\\]src$' |
| 88 |
|
| 89 |
go list ./builtin |
| 90 |
stdout '^std/builtin$' # Only the "std" in actual $GOROOT is special, and only its "builtin" is special. |
| 91 |
|
| 92 |
! go list ./bytes |
| 93 |
! stderr 'cannot find module providing package' |
| 94 |
stderr '^no Go files in '$WORK'[/\\]othergoroot[/\\]src[/\\]bytes$' |
| 95 |
|
| 96 |
! go list ./vendor/golang.org/x/net/http2/hpack |
| 97 |
stderr '^without -mod=vendor, directory '$WORK'[/\\]othergoroot[/\\]src[/\\]vendor[/\\]golang.org[/\\]x[/\\]net[/\\]http2[/\\]hpack has no package path$' |
| 98 |
|
| 99 |
-- dir/go.mod -- |
| 100 |
module example.com |
| 101 |
go 1.13 |
| 102 |
-- dir/subdir/README -- |
| 103 |
There are no Go source files in this directory. |
| 104 |
-- dir/othermodule/go.mod -- |
| 105 |
module example.com/othermodule |
| 106 |
go 1.13 |
| 107 |
-- dir/othermodule/om.go -- |
| 108 |
package othermodule |
| 109 |
-- dir/testdata/td.go -- |
| 110 |
package testdata |
| 111 |
-- dir/vendor/modules.txt -- |
| 112 |
# pkg v0.0.0 |
| 113 |
pkg |
| 114 |
-- dir/vendor/nonexist/README -- |
| 115 |
There are no Go source files here either. |
| 116 |
-- dir/vendor/pkg/pkg.go -- |
| 117 |
package pkg |
| 118 |
-- dir/vendor/unlisted/unlisted.go -- |
| 119 |
package unlisted |
| 120 |
-- emptyroot/go.mod -- |
| 121 |
module example.com/emptyroot |
| 122 |
-- emptyroot/pkg/pkg.go -- |
| 123 |
package pkg |
| 124 |
-- $WORK/othergoroot/src/go.mod -- |
| 125 |
module std |
| 126 |
go 1.13 |
| 127 |
-- $WORK/othergoroot/src/builtin/builtin.go -- |
| 128 |
package builtin |
| 129 |
-- $WORK/othergoroot/src/bytes/README -- |
| 130 |
There are no Go source files in this directory. |
| 131 |
-- $WORK/othergoroot/src/vendor/golang.org/x/net/http2/hpack -- |
| 132 |
package hpack |