github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_std_vendor.txt (about) 1 env GO111MODULE=on 2 env GOPROXY=off 3 4 [!gc] skip 5 6 # 'go list' should report imports from _test.go in the TestImports field. 7 go list -f '{{.TestImports}}' 8 stdout net/http # from .TestImports 9 10 # 'go list' should find standard-vendored packages. 11 go list -f '{{.Dir}}' vendor/golang.org/x/net/http2/hpack 12 stdout $GOROOT[/\\]src[/\\]vendor 13 14 # 'go list -test' should report vendored transitive dependencies of _test.go 15 # imports in the Deps field. 16 go list -test -f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' 17 stdout ^vendor/golang.org/x/crypto # dep of .TestImports 18 19 20 # Modules outside the standard library should not use the packages vendored there... 21 cd broken 22 ! go build -mod=readonly 23 stderr 'disabled by -mod=readonly' 24 ! go build -mod=vendor 25 stderr 'cannot find package' 26 stderr 'hpack' 27 28 # ...even if they explicitly use the "cmd/vendor/" or "vendor/" prefix. 29 cd ../importcmd 30 ! go build . 31 stderr 'use of vendored package' 32 33 cd ../importstd 34 ! go build . 35 stderr 'use of vendored package' 36 37 38 # When run within the 'std' module, 'go list -test' should report vendored 39 # transitive dependencies at their original module paths. 40 # TODO(golang.org/issue/30241): Make that work. 41 # Today, they're standard packages as long as they exist. 42 cd $GOROOT/src 43 go list -test -f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' net/http 44 stdout ^vendor/golang.org/x/net/http2/hpack # TODO: remove vendor/ prefix 45 ! stdout ^golang.org/x/net/http2/hpack 46 47 -- go.mod -- 48 module m 49 50 -- x.go -- 51 package x 52 53 -- x_test.go -- 54 package x 55 import "testing" 56 import _ "net/http" 57 func Test(t *testing.T) {} 58 59 -- broken/go.mod -- 60 module broken 61 -- broken/http.go -- 62 package broken 63 64 import ( 65 _ "net/http" 66 _ "golang.org/x/net/http2/hpack" 67 ) 68 69 -- importcmd/go.mod -- 70 module importcmd 71 -- importcmd/x.go -- 72 package importcmd 73 74 import _ "cmd/vendor/golang.org/x/tools/go/analysis" 75 -- importstd/go.mod -- 76 module importvendor 77 -- importstd/x.go -- 78 package importstd 79 80 import _ "vendor/golang.org/x/net/http2/hpack"