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

     1  # This test exercises that vendoring works properly using the workspace in the
     2  # the work_prune test case.
     3  
     4  go work vendor
     5  cmp vendor/modules.txt modules.txt.want
     6  cmp vendor/example.com/b/b.go b/b.go
     7  cmp vendor/example.com/q/q.go q1_1_0/q.go
     8  go list -m -f '{{.Version}}' example.com/q
     9  stdout '^v1.1.0$'
    10  
    11  go list -f '{{.Dir}}' example.com/q
    12  stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]q
    13  go list -f '{{.Dir}}' example.com/b
    14  stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]b
    15  
    16  [short] skip
    17  
    18  rm b
    19  rm q1_0_0
    20  rm q1_1_0
    21  go run example.com/p
    22  stdout 'version 1.1.0'
    23  
    24  -- modules.txt.want --
    25  ## workspace
    26  # example.com/b v1.0.0 => ./b
    27  ## explicit; go 1.18
    28  example.com/b
    29  # example.com/q v1.0.0 => ./q1_0_0
    30  ## explicit; go 1.18
    31  # example.com/q v1.1.0 => ./q1_1_0
    32  ## go 1.18
    33  example.com/q
    34  -- go.work --
    35  go 1.18
    36  
    37  use (
    38  	./a
    39  	./p
    40  )
    41  -- a/go.mod --
    42  module example.com/a
    43  
    44  go 1.18
    45  
    46  require example.com/b v1.0.0
    47  
    48  replace example.com/b v1.0.0 => ../b
    49  -- a/foo.go --
    50  package main
    51  
    52  import "example.com/b"
    53  
    54  func main() {
    55  	b.B()
    56  }
    57  -- b/go.mod --
    58  module example.com/b
    59  
    60  go 1.18
    61  
    62  require example.com/q v1.1.0
    63  -- b/b.go --
    64  package b
    65  
    66  func B() {
    67  }
    68  -- b/b_test.go --
    69  package b
    70  
    71  import "example.com/q"
    72  
    73  func TestB() {
    74  	q.PrintVersion()
    75  }
    76  -- p/go.mod --
    77  module example.com/p
    78  
    79  go 1.18
    80  
    81  require example.com/q v1.0.0
    82  
    83  replace example.com/q v1.0.0 => ../q1_0_0
    84  replace example.com/q v1.1.0 => ../q1_1_0
    85  -- p/main.go --
    86  package main
    87  
    88  import "example.com/q"
    89  
    90  func main() {
    91  	q.PrintVersion()
    92  }
    93  -- q1_0_0/go.mod --
    94  module example.com/q
    95  
    96  go 1.18
    97  -- q1_0_0/q.go --
    98  package q
    99  
   100  import "fmt"
   101  
   102  func PrintVersion() {
   103  	fmt.Println("version 1.0.0")
   104  }
   105  -- q1_1_0/go.mod --
   106  module example.com/q
   107  
   108  go 1.18
   109  -- q1_1_0/q.go --
   110  package q
   111  
   112  import "fmt"
   113  
   114  func PrintVersion() {
   115  	fmt.Println("version 1.1.0")
   116  }
   117  

View as plain text