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

     1  # Test editing go.work files.
     2  
     3  go work init m
     4  cmpenv go.work go.work.want_initial
     5  
     6  go work edit -use n
     7  cmpenv go.work go.work.want_use_n
     8  
     9  go work edit -go 1.18
    10  cmp go.work go.work.want_go_118
    11  
    12  go work edit -dropuse m
    13  cmp go.work go.work.want_dropuse_m
    14  
    15  go work edit -replace=x.1@v1.3.0=y.1@v1.4.0 -replace='x.1@v1.4.0 = ../z'
    16  cmp go.work go.work.want_add_replaces
    17  
    18  go work edit -use n -use ../a -use /b -use c -use c
    19  cmp go.work go.work.want_multiuse
    20  
    21  go work edit -dropuse /b -dropuse n
    22  cmp go.work go.work.want_multidropuse
    23  
    24  go work edit -dropreplace='x.1@v1.4.0'
    25  cmp go.work go.work.want_dropreplace
    26  
    27  go work edit -print -go 1.19 -use b -dropuse c -replace 'x.1@v1.4.0 = ../z' -dropreplace x.1 -dropreplace x.1@v1.3.0
    28  cmp stdout go.work.want_print
    29  
    30  go work edit -json -go 1.19 -use b -dropuse c -replace 'x.1@v1.4.0 = ../z' -dropreplace x.1 -dropreplace x.1@v1.3.0
    31  cmp stdout go.work.want_json
    32  
    33  env GOWORK=$GOPATH/src/unformatted
    34  go work edit -print -fmt
    35  cmp stdout formatted
    36  
    37  -- m/go.mod --
    38  module m
    39  
    40  go 1.18
    41  -- go.work.want_initial --
    42  go $goversion
    43  
    44  use ./m
    45  -- go.work.want_use_n --
    46  go $goversion
    47  
    48  use (
    49  	./m
    50  	./n
    51  )
    52  -- go.work.want_go_118 --
    53  go 1.18
    54  
    55  use (
    56  	./m
    57  	./n
    58  )
    59  -- go.work.want_dropuse_m --
    60  go 1.18
    61  
    62  use ./n
    63  -- go.work.want_add_replaces --
    64  go 1.18
    65  
    66  use ./n
    67  
    68  replace (
    69  	x.1 v1.3.0 => y.1 v1.4.0
    70  	x.1 v1.4.0 => ../z
    71  )
    72  -- go.work.want_multiuse --
    73  go 1.18
    74  
    75  use (
    76  	../a
    77  	./c
    78  	./n
    79  	/b
    80  )
    81  
    82  replace (
    83  	x.1 v1.3.0 => y.1 v1.4.0
    84  	x.1 v1.4.0 => ../z
    85  )
    86  -- go.work.want_multidropuse --
    87  go 1.18
    88  
    89  use (
    90  	../a
    91  	./c
    92  )
    93  
    94  replace (
    95  	x.1 v1.3.0 => y.1 v1.4.0
    96  	x.1 v1.4.0 => ../z
    97  )
    98  -- go.work.want_dropreplace --
    99  go 1.18
   100  
   101  use (
   102  	../a
   103  	./c
   104  )
   105  
   106  replace x.1 v1.3.0 => y.1 v1.4.0
   107  -- go.work.want_print --
   108  go 1.19
   109  
   110  use (
   111  	../a
   112  	./b
   113  )
   114  
   115  replace x.1 v1.4.0 => ../z
   116  -- go.work.want_json --
   117  {
   118  	"Go": "1.19",
   119  	"Use": [
   120  		{
   121  			"DiskPath": "../a"
   122  		},
   123  		{
   124  			"DiskPath": "./b"
   125  		}
   126  	],
   127  	"Replace": [
   128  		{
   129  			"Old": {
   130  				"Path": "x.1",
   131  				"Version": "v1.4.0"
   132  			},
   133  			"New": {
   134  				"Path": "../z"
   135  			}
   136  		}
   137  	]
   138  }
   139  -- unformatted --
   140  go 1.18
   141   use (
   142   a
   143    b
   144    c
   145    )
   146    replace (
   147    x.1 v1.3.0 => y.1 v1.4.0
   148                              x.1 v1.4.0 => ../z
   149                              )
   150  -- formatted --
   151  go 1.18
   152  
   153  use (
   154  	a
   155  	b
   156  	c
   157  )
   158  
   159  replace (
   160  	x.1 v1.3.0 => y.1 v1.4.0
   161  	x.1 v1.4.0 => ../z
   162  )

View as plain text