Skip to content

Commit f0888c3

Browse files
committed
docs: add migration guide
1 parent a2b6412 commit f0888c3

File tree

2 files changed

+370
-1
lines changed

2 files changed

+370
-1
lines changed

docs/src/config/sidebar.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
link: "/product/thanks/"
2727
- label: "Changelog"
2828
link: "/product/changelog/"
29+
- label: "Migration Guide"
30+
link: "/product/migration-guide/"
2931
- label: "Roadmap"
3032
link: "/product/roadmap/"
3133
- label: "Performance"
@@ -54,4 +56,3 @@
5456
link: /plugins/module-plugins/
5557
- label: Go Plugin System
5658
link: /plugins/go-plugins/
57-
+368
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,368 @@
1+
---
2+
title: Migration guide
3+
---
4+
5+
## Migrating configuration from v1 to v2
6+
7+
Golangci-lint v2 has slightly different configuration options than v1.
8+
Some options were renamed, some were moved, some were split, and some were removed.
9+
Here is a guide how to migrate your v1 configuration.
10+
11+
You can use `golangci-lint` itself to migrate your configuration automatically through the `migrate` command:
12+
13+
```sh
14+
golangci-lint migrate
15+
```
16+
17+
In case you want to do it manually, here is a list of changes.
18+
19+
---
20+
21+
### `linters` configuration
22+
23+
#### Replaced
24+
25+
1. `linters.disable-all` replaced with `linters.default: none`.
26+
27+
<details>
28+
<summary>v1</summary>
29+
30+
```yaml
31+
linters:
32+
disable-all: true
33+
```
34+
35+
</details>
36+
37+
<details>
38+
<summary>v2</summary>
39+
40+
```yaml
41+
linters:
42+
default: none
43+
```
44+
45+
</details>
46+
47+
See [golangci-lint#5474](https://github.com/golangci/golangci-lint/pull/5475) for more details.
48+
49+
2. `linters.enable-all` replaced with `linters.default: all`.
50+
51+
<details>
52+
<summary>v1</summary>
53+
54+
```yaml
55+
linters:
56+
enable-all: true
57+
```
58+
59+
</details>
60+
61+
<details>
62+
<summary>v2</summary>
63+
64+
```yaml
65+
linters:
66+
default: all
67+
```
68+
69+
</details>
70+
71+
See [golangci-lint#5474](https://github.com/golangci/golangci-lint/pull/5475) for more details.
72+
73+
---
74+
75+
### `linters-settings` configuration
76+
77+
#### Split
78+
79+
1. `linters-settings` section split to `linters.settings` and `formatters.settings`.
80+
81+
Most linters settings are now in the `linters.settings` section.
82+
Settings for `gci`, `gofmt`, `gofumpt`, `goimports` are moved to the `formatters.settings` section.
83+
84+
<details>
85+
<summary>v1</summary>
86+
87+
```yaml
88+
linters-settings:
89+
gofmt:
90+
simplify: true
91+
govet:
92+
disable-all: true
93+
```
94+
95+
</details>
96+
97+
<details>
98+
<summary>v2</summary>
99+
100+
```yaml
101+
linters:
102+
settings:
103+
govet:
104+
disable-all: true
105+
106+
formatters:
107+
settings:
108+
gofmt:
109+
simplify: true
110+
```
111+
112+
</details>
113+
114+
See [golangci-lint#5474](https://github.com/golangci/golangci-lint/pull/5475) for more details.
115+
116+
---
117+
118+
### `issues` configuration
119+
120+
#### Removed
121+
122+
1. `issues.exclude-case-sensitive` option.
123+
124+
`issues.exclude` and `issues.exclude-rules` are case sensitive by default.
125+
To ignore case, use `(?i)` at the beginning of a regex syntax.
126+
127+
<details>
128+
<summary>v1</summary>
129+
130+
```yaml
131+
issues:
132+
exclude-case-sensitive: false
133+
exclude:
134+
- 'abcdef'
135+
```
136+
137+
</details>
138+
139+
<details>
140+
<summary>v2</summary>
141+
142+
```yaml
143+
issues:
144+
exclude:
145+
- '(?i)abcdef'
146+
```
147+
148+
</details>
149+
150+
See [golangci-lint#5451](https://github.com/golangci/golangci-lint/pull/5451) for more details.
151+
152+
2. `issues.exclude-dirs-use-default` option.
153+
154+
<details>
155+
<summary>v1</summary>
156+
157+
```yaml
158+
issues:
159+
exclude-dirs-use-default: false
160+
```
161+
162+
</details>
163+
164+
<details>
165+
<summary>v2</summary>
166+
167+
TODO
168+
169+
</details>
170+
171+
172+
See [golangci-lint#5451](https://github.com/golangci/golangci-lint/pull/5451) for more details.
173+
174+
#### Replaced
175+
176+
1. `exclude-dirs` and `exclude-files` replaced with `exclusions.paths`.
177+
178+
<details>
179+
<summary>v1</summary>
180+
181+
```yaml
182+
issues:
183+
exclude-dirs:
184+
- src/external_libs
185+
- autogenerated_by_my_lib
186+
187+
exclude-files:
188+
- ".*\\.my\\.go$"
189+
- lib/bad.go
190+
```
191+
192+
</details>
193+
194+
<details>
195+
<summary>v2</summary>
196+
197+
```yaml
198+
issues:
199+
exclusions:
200+
paths:
201+
- src/external_libs
202+
- autogenerated_by_my_lib
203+
- ".*\\.my\\.go$"
204+
- lib/bad.go
205+
```
206+
207+
</details>
208+
209+
2. `issues.exclude-generated-strict` and `issues.exclude-generated` replaced with `linters.exclusions.generated`.
210+
211+
<details>
212+
<summary>v1</summary>
213+
214+
```yaml
215+
issues:
216+
exclude-generated-strict: true
217+
exclude-generated: strict
218+
```
219+
220+
</details>
221+
222+
<details>
223+
<summary>v2</summary>
224+
225+
```yaml
226+
linters:
227+
exclusions:
228+
generated: strict
229+
```
230+
231+
</details>
232+
233+
---
234+
235+
### `output` configuration
236+
237+
#### Replaced
238+
239+
1. `output.format` replaced with `output.formats`.
240+
241+
Deprecated since [v1.57.0](https://golangci-lint.run/product/changelog/#v1570).
242+
243+
<details>
244+
<summary>v1</summary>
245+
246+
```yaml
247+
output:
248+
format: "checkstyle:report.xml,json:stdout,colored-line-number"
249+
```
250+
251+
</details>
252+
253+
<details>
254+
<summary>v2</summary>
255+
256+
```yaml
257+
output:
258+
formats:
259+
- format: checkstyle
260+
path: report.xml
261+
- format: json
262+
path: stdout
263+
- format: colored-line-number
264+
```
265+
266+
</details>
267+
268+
See [golangci-lint#4521](https://github.com/golangci/golangci-lint/pull/4521) for more details.
269+
270+
#### Changed
271+
272+
1. `output.show-stats` is `true` by default.
273+
274+
<details>
275+
<summary>v1</summary>
276+
277+
```yaml
278+
output:
279+
# show-stats is not present
280+
```
281+
282+
</details>
283+
284+
<details>
285+
<summary>v2</summary>
286+
287+
```yaml
288+
output:
289+
show-stats: true
290+
```
291+
292+
</details>
293+
294+
See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details.
295+
296+
---
297+
298+
### `run` configuration
299+
300+
#### Changed
301+
302+
1. `run.go` fallback to `1.23`.
303+
304+
In v1, `run.go` fallback to `1.17`.
305+
306+
See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details.
307+
308+
2. `run.timeout` is `0` (disabled) by default.
309+
310+
In v1, `run.timeout` was `1m` by default.
311+
312+
<details>
313+
<summary>v1</summary>
314+
315+
```yaml
316+
run:
317+
# timeout is not present
318+
```
319+
320+
</details>
321+
322+
<details>
323+
<summary>v2</summary>
324+
325+
```yaml
326+
run:
327+
timeout: 1m
328+
```
329+
330+
</details>
331+
332+
See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details.
333+
334+
3. `run.concurrency` set to match Linux container CPU quota by default.
335+
336+
In v1, `run.concurrency` was set to the number of logical CPUs in the machine.
337+
338+
See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details.
339+
340+
---
341+
342+
### `severity` configuration
343+
344+
#### Renamed
345+
346+
1. `severity.default-severity` renamed to `severity.default`.
347+
348+
<details>
349+
<summary>v1</summary>
350+
351+
```yaml
352+
severity:
353+
default-severity: error
354+
```
355+
356+
</details>
357+
358+
<details>
359+
<summary>v2</summary>
360+
361+
```yaml
362+
severity:
363+
default: error
364+
```
365+
366+
</details>
367+
368+
See [golangci-lint#5462](https://github.com/golangci/golangci-lint/pull/5462) for more details.

0 commit comments

Comments
 (0)