...

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

Documentation: cmd/go/testdata/script

     1# This test exercises that vendoring works properly using the workspace in the
     2# the work_prune test case.
     3
     4go work vendor
     5cmp vendor/modules.txt modules.txt.want
     6go list -f '{{with .Module}}{{.Path}}@{{.Version}}{{end}}' all
     7cmp stdout want_versions
     8
     9go list -f '{{.Dir}}' example.com/q
    10stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]q
    11go list -f '{{.Dir}}' example.com/b
    12stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]b
    13go list -f '{{.Dir}}' example.com/w
    14stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]w
    15go list -f '{{.Dir}}' example.com/z
    16stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]z
    17
    18cmp $GOPATH/src/vendor/example.com/q/q.go q1_1_0/q.go
    19
    20-- modules.txt.want --
    21## workspace
    22# example.com/b v1.0.0 => ./b
    23## explicit; go 1.18
    24example.com/b
    25# example.com/q v1.0.0 => ./q1_0_0
    26## explicit; go 1.18
    27# example.com/q v1.1.0 => ./q1_1_0
    28## go 1.18
    29example.com/q
    30# example.com/w v1.0.0 => ./w
    31## go 1.18
    32example.com/w
    33# example.com/z v1.0.0 => ./z1_0_0
    34## explicit; go 1.18
    35# example.com/z v1.1.0 => ./z1_1_0
    36## go 1.18
    37example.com/z
    38# example.com/q v1.0.5 => ./q1_0_5
    39# example.com/r v1.0.0 => ./r
    40# example.com/x v1.0.0 => ./x
    41# example.com/y v1.0.0 => ./y
    42-- want_versions --
    43example.com/a@
    44example.com/b@v1.0.0
    45example.com/p@
    46example.com/q@v1.1.0
    47example.com/w@v1.0.0
    48example.com/z@v1.1.0
    49-- go.work --
    50go 1.18
    51
    52use (
    53	./a
    54	./p
    55)
    56
    57replace example.com/b v1.0.0 => ./b
    58replace example.com/q v1.0.0 => ./q1_0_0
    59replace example.com/q v1.0.5 => ./q1_0_5
    60replace example.com/q v1.1.0 => ./q1_1_0
    61replace example.com/r v1.0.0 => ./r
    62replace example.com/w v1.0.0 => ./w
    63replace example.com/x v1.0.0 => ./x
    64replace example.com/y v1.0.0 => ./y
    65replace example.com/z v1.0.0 => ./z1_0_0
    66replace example.com/z v1.1.0 => ./z1_1_0
    67
    68-- a/go.mod --
    69module example.com/a
    70
    71go 1.18
    72
    73require example.com/b v1.0.0
    74require example.com/z v1.0.0
    75-- a/foo.go --
    76package main
    77
    78import "example.com/b"
    79
    80func main() {
    81	b.B()
    82}
    83-- b/go.mod --
    84module example.com/b
    85
    86go 1.18
    87
    88require example.com/q v1.1.0
    89-- b/b.go --
    90package b
    91
    92func B() {
    93}
    94-- p/go.mod --
    95module example.com/p
    96
    97go 1.18
    98
    99require example.com/q v1.0.0
   100
   101replace example.com/q v1.0.0 => ../q1_0_0
   102replace example.com/q v1.1.0 => ../q1_1_0
   103-- p/main.go --
   104package main
   105
   106import "example.com/q"
   107
   108func main() {
   109	q.PrintVersion()
   110}
   111-- q1_0_0/go.mod --
   112module example.com/q
   113
   114go 1.18
   115-- q1_0_0/q.go --
   116package q
   117
   118import "fmt"
   119
   120func PrintVersion() {
   121	fmt.Println("version 1.0.0")
   122}
   123-- q1_0_5/go.mod --
   124module example.com/q
   125
   126go 1.18
   127
   128require example.com/r v1.0.0
   129-- q1_0_5/q.go --
   130package q
   131
   132import _ "example.com/r"
   133-- q1_1_0/go.mod --
   134module example.com/q
   135
   136require example.com/w v1.0.0
   137require example.com/z v1.1.0
   138
   139go 1.18
   140-- q1_1_0/q.go --
   141package q
   142
   143import _ "example.com/w"
   144import _ "example.com/z"
   145
   146import "fmt"
   147
   148func PrintVersion() {
   149	fmt.Println("version 1.1.0")
   150}
   151-- r/go.mod --
   152module example.com/r
   153
   154go 1.18
   155
   156require example.com/r v1.0.0
   157-- r/r.go --
   158package r
   159-- w/go.mod --
   160module example.com/w
   161
   162go 1.18
   163
   164require example.com/x v1.0.0
   165-- w/w.go --
   166package w
   167-- w/w_test.go --
   168package w
   169
   170import _ "example.com/x"
   171-- x/go.mod --
   172module example.com/x
   173
   174go 1.18
   175-- x/x.go --
   176package x
   177-- x/x_test.go --
   178package x
   179import _ "example.com/y"
   180-- y/go.mod --
   181module example.com/y
   182
   183go 1.18
   184-- y/y.go --
   185package y
   186-- z1_0_0/go.mod --
   187module example.com/z
   188
   189go 1.18
   190
   191require example.com/q v1.0.5
   192-- z1_0_0/z.go --
   193package z
   194
   195import _ "example.com/q"
   196-- z1_1_0/go.mod --
   197module example.com/z
   198
   199go 1.18
   200-- z1_1_0/z.go --
   201package z

View as plain text