...

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

Documentation: cmd/go/testdata/script

     1# Test editing go.work files.
     2
     3go work init m
     4cmpenv go.work go.work.want_initial
     5
     6go work edit -use n
     7cmpenv go.work go.work.want_use_n
     8
     9grep go go.work
    10go work edit -go none
    11! grep go go.work
    12
    13go work edit -go 1.18
    14cmp go.work go.work.want_go_118
    15
    16go work edit -dropuse m
    17cmp go.work go.work.want_dropuse_m
    18
    19go work edit -replace=x.1@v1.3.0=y.1@v1.4.0 -replace='x.1@v1.4.0 = ../z'
    20cmp go.work go.work.want_add_replaces
    21
    22go work edit -use n -use ../a -use /b -use c -use c
    23cmp go.work go.work.want_multiuse
    24
    25go work edit -dropuse /b -dropuse n
    26cmp go.work go.work.want_multidropuse
    27
    28go work edit -dropreplace='x.1@v1.4.0'
    29cmp go.work go.work.want_dropreplace
    30
    31go 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
    32cmp stdout go.work.want_print
    33
    34go 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
    35cmp stdout go.work.want_json
    36
    37# go work edit -godebug
    38cd $WORK/g
    39cp go.work.start go.work
    40go work edit -godebug key=value
    41cmpenv go.work go.work.edit
    42go work edit -dropgodebug key2
    43cmpenv go.work go.work.edit
    44go work edit -dropgodebug key
    45cmpenv go.work go.work.start
    46
    47# go work edit -print -fmt
    48env GOWORK=$GOPATH/src/unformatted
    49go work edit -print -fmt
    50cmp stdout $GOPATH/src/formatted
    51
    52-- m/go.mod --
    53module m
    54
    55go 1.18
    56-- go.work.want_initial --
    57go $goversion
    58
    59use ./m
    60-- go.work.want_use_n --
    61go $goversion
    62
    63use (
    64	./m
    65	./n
    66)
    67-- go.work.want_go_118 --
    68go 1.18
    69
    70use (
    71	./m
    72	./n
    73)
    74-- go.work.want_dropuse_m --
    75go 1.18
    76
    77use ./n
    78-- go.work.want_add_replaces --
    79go 1.18
    80
    81use ./n
    82
    83replace (
    84	x.1 v1.3.0 => y.1 v1.4.0
    85	x.1 v1.4.0 => ../z
    86)
    87-- go.work.want_multiuse --
    88go 1.18
    89
    90use (
    91	../a
    92	./c
    93	./n
    94	/b
    95)
    96
    97replace (
    98	x.1 v1.3.0 => y.1 v1.4.0
    99	x.1 v1.4.0 => ../z
   100)
   101-- go.work.want_multidropuse --
   102go 1.18
   103
   104use (
   105	../a
   106	./c
   107)
   108
   109replace (
   110	x.1 v1.3.0 => y.1 v1.4.0
   111	x.1 v1.4.0 => ../z
   112)
   113-- go.work.want_dropreplace --
   114go 1.18
   115
   116use (
   117	../a
   118	./c
   119)
   120
   121replace x.1 v1.3.0 => y.1 v1.4.0
   122-- go.work.want_print --
   123go 1.19
   124
   125use (
   126	../a
   127	./b
   128)
   129
   130replace 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 --
   155go 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 --
   166go 1.18
   167
   168use (
   169	a
   170	b
   171	c
   172)
   173
   174replace (
   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 --
   179use g
   180
   181go 1.10
   182-- $WORK/g/go.work.edit --
   183use g
   184
   185go 1.10
   186
   187godebug key=value

View as plain text