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  grep go go.work
    10  go work edit -go none
    11  ! grep go go.work
    12  
    13  go work edit -go 1.18
    14  cmp go.work go.work.want_go_118
    15  
    16  go work edit -dropuse m
    17  cmp go.work go.work.want_dropuse_m
    18  
    19  go work edit -replace=x.1@v1.3.0=y.1@v1.4.0 -replace='x.1@v1.4.0 = ../z'
    20  cmp go.work go.work.want_add_replaces
    21  
    22  go work edit -use n -use ../a -use /b -use c -use c
    23  cmp go.work go.work.want_multiuse
    24  
    25  go work edit -dropuse /b -dropuse n
    26  cmp go.work go.work.want_multidropuse
    27  
    28  go work edit -dropreplace='x.1@v1.4.0'
    29  cmp go.work go.work.want_dropreplace
    30  
    31  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
    32  cmp stdout go.work.want_print
    33  
    34  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
    35  cmp stdout go.work.want_json
    36  
    37  # go work edit -godebug
    38  cd $WORK/g
    39  cp go.work.start go.work
    40  go work edit -godebug key=value
    41  cmpenv go.work go.work.edit
    42  go work edit -dropgodebug key2
    43  cmpenv go.work go.work.edit
    44  go work edit -dropgodebug key
    45  cmpenv go.work go.work.start
    46  
    47  # go work edit -print -fmt
    48  env GOWORK=$GOPATH/src/unformatted
    49  go work edit -print -fmt
    50  cmp stdout $GOPATH/src/formatted
    51  
    52  -- m/go.mod --
    53  module m
    54  
    55  go 1.18
    56  -- go.work.want_initial --
    57  go $goversion
    58  
    59  use ./m
    60  -- go.work.want_use_n --
    61  go $goversion
    62  
    63  use (
    64  	./m
    65  	./n
    66  )
    67  -- go.work.want_go_118 --
    68  go 1.18
    69  
    70  use (
    71  	./m
    72  	./n
    73  )
    74  -- go.work.want_dropuse_m --
    75  go 1.18
    76  
    77  use ./n
    78  -- go.work.want_add_replaces --
    79  go 1.18
    80  
    81  use ./n
    82  
    83  replace (
    84  	x.1 v1.3.0 => y.1 v1.4.0
    85  	x.1 v1.4.0 => ../z
    86  )
    87  -- go.work.want_multiuse --
    88  go 1.18
    89  
    90  use (
    91  	../a
    92  	./c
    93  	./n
    94  	/b
    95  )
    96  
    97  replace (
    98  	x.1 v1.3.0 => y.1 v1.4.0
    99  	x.1 v1.4.0 => ../z
   100  )
   101  -- go.work.want_multidropuse --
   102  go 1.18
   103  
   104  use (
   105  	../a
   106  	./c
   107  )
   108  
   109  replace (
   110  	x.1 v1.3.0 => y.1 v1.4.0
   111  	x.1 v1.4.0 => ../z
   112  )
   113  -- go.work.want_dropreplace --
   114  go 1.18
   115  
   116  use (
   117  	../a
   118  	./c
   119  )
   120  
   121  replace x.1 v1.3.0 => y.1 v1.4.0
   122  -- go.work.want_print --
   123  go 1.19
   124  
   125  use (
   126  	../a
   127  	./b
   128  )
   129  
   130  replace x.1 v1.4.0 => ../z
   131  -- go.work.want_json --
   132  {
   133  	"Go": "1.19",
   134  	"Use": [
   135  		{
   136  			"DiskPath": "../a"
   137  		},
   138  		{
   139  			"DiskPath": "./b"
   140  		}
   141  	],
   142  	"Replace": [
   143  		{
   144  			"Old": {
   145  				"Path": "x.1",
   146  				"Version": "v1.4.0"
   147  			},
   148  			"New": {
   149  				"Path": "../z"
   150  			}
   151  		}
   152  	]
   153  }
   154  -- unformatted --
   155  go 1.18
   156   use (
   157   a
   158    b
   159    c
   160    )
   161    replace (
   162    x.1 v1.3.0 => y.1 v1.4.0
   163                              x.1 v1.4.0 => ../z
   164                              )
   165  -- formatted --
   166  go 1.18
   167  
   168  use (
   169  	a
   170  	b
   171  	c
   172  )
   173  
   174  replace (
   175  	x.1 v1.3.0 => y.1 v1.4.0
   176  	x.1 v1.4.0 => ../z
   177  )
   178  -- $WORK/g/go.work.start --
   179  use g
   180  
   181  go 1.10
   182  -- $WORK/g/go.work.edit --
   183  use g
   184  
   185  go 1.10
   186  
   187  godebug key=value
   188  

View as plain text