...
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
37env GOWORK=$GOPATH/src/unformatted
38go work edit -print -fmt
39cmp stdout formatted
40
41-- m/go.mod --
42module m
43
44go 1.18
45-- go.work.want_initial --
46go $goversion
47
48use ./m
49-- go.work.want_use_n --
50go $goversion
51
52use (
53 ./m
54 ./n
55)
56-- go.work.want_go_118 --
57go 1.18
58
59use (
60 ./m
61 ./n
62)
63-- go.work.want_dropuse_m --
64go 1.18
65
66use ./n
67-- go.work.want_add_replaces --
68go 1.18
69
70use ./n
71
72replace (
73 x.1 v1.3.0 => y.1 v1.4.0
74 x.1 v1.4.0 => ../z
75)
76-- go.work.want_multiuse --
77go 1.18
78
79use (
80 ../a
81 ./c
82 ./n
83 /b
84)
85
86replace (
87 x.1 v1.3.0 => y.1 v1.4.0
88 x.1 v1.4.0 => ../z
89)
90-- go.work.want_multidropuse --
91go 1.18
92
93use (
94 ../a
95 ./c
96)
97
98replace (
99 x.1 v1.3.0 => y.1 v1.4.0
100 x.1 v1.4.0 => ../z
101)
102-- go.work.want_dropreplace --
103go 1.18
104
105use (
106 ../a
107 ./c
108)
109
110replace x.1 v1.3.0 => y.1 v1.4.0
111-- go.work.want_print --
112go 1.19
113
114use (
115 ../a
116 ./b
117)
118
119replace x.1 v1.4.0 => ../z
120-- go.work.want_json --
121{
122 "Go": "1.19",
123 "Use": [
124 {
125 "DiskPath": "../a"
126 },
127 {
128 "DiskPath": "./b"
129 }
130 ],
131 "Replace": [
132 {
133 "Old": {
134 "Path": "x.1",
135 "Version": "v1.4.0"
136 },
137 "New": {
138 "Path": "../z"
139 }
140 }
141 ]
142}
143-- unformatted --
144go 1.18
145 use (
146 a
147 b
148 c
149 )
150 replace (
151 x.1 v1.3.0 => y.1 v1.4.0
152 x.1 v1.4.0 => ../z
153 )
154-- formatted --
155go 1.18
156
157use (
158 a
159 b
160 c
161)
162
163replace (
164 x.1 v1.3.0 => y.1 v1.4.0
165 x.1 v1.4.0 => ../z
166)
View as plain text