Text file src/cmd/go/testdata/script/mod_std_vendor.txt

     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 vendored paths.
    40  cd $GOROOT/src
    41  go list -test -f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' net/http
    42  ! stdout ^golang.org/x/net/http2/hpack
    43  stdout ^vendor/golang.org/x/net/http2/hpack
    44  
    45  -- go.mod --
    46  module m
    47  
    48  -- x.go --
    49  package x
    50  
    51  -- x_test.go --
    52  package x
    53  import "testing"
    54  import _ "net/http"
    55  func Test(t *testing.T) {}
    56  
    57  -- broken/go.mod --
    58  module broken
    59  -- broken/http.go --
    60  package broken
    61  
    62  import (
    63  	_ "net/http"
    64  	_ "golang.org/x/net/http2/hpack"
    65  )
    66  
    67  -- importcmd/go.mod --
    68  module importcmd
    69  -- importcmd/x.go --
    70  package importcmd
    71  
    72  import _ "cmd/vendor/golang.org/x/tools/go/analysis"
    73  -- importstd/go.mod --
    74  module importvendor
    75  -- importstd/x.go --
    76  package importstd
    77  
    78  import _ "vendor/golang.org/x/net/http2/hpack"
    79  

View as plain text