Skip to content

Commit fe05552

Browse files
committed
chore: migrate golangci from v1 to v2
1 parent 3b1d651 commit fe05552

File tree

2 files changed

+59
-120
lines changed

2 files changed

+59
-120
lines changed

.github/workflows/go-validate.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ jobs:
4949
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
5050
with:
5151
go-version: ${{ needs.get-go-version.outputs.go-version }}
52-
- uses: golangci/golangci-lint-action@82d40c283aeb1f2b6595839195e95c2d6a49081b # v5.0.0
53-
with:
54-
version: v1.60.1
55-
only-new-issues: true
52+
- uses: golangci/golangci-lint-action@v8.0.0
5653
check-fmt:
5754
needs:
5855
- get-go-version

.golangci.yml

Lines changed: 58 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,70 @@
11
# Copyright (c) HashiCorp, Inc.
22
# SPDX-License-Identifier: MPL-2.0
33

4-
issues:
5-
# List of regexps of issue texts to exclude, empty list by default.
6-
# But independently from this option we use default exclude patterns,
7-
# it can be disabled by `exclude-use-default: false`. To list all
8-
# excluded by default patterns execute `golangci-lint run --help`
9-
10-
exclude-rules:
11-
# Exclude gosimple bool check
12-
- linters:
13-
- gosimple
14-
text: "S(1002|1008|1021)"
15-
# Exclude failing staticchecks for now
16-
- linters:
17-
- staticcheck
18-
text: "SA(1006|1019|4006|4010|4017|5007|6005|9004):"
19-
# Exclude lll issues for long lines with go:generate
20-
- linters:
21-
- lll
22-
source: "^//go:generate "
23-
- linters:
24-
- errcheck
25-
path: ".*_test.go"
26-
27-
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
28-
max-issues-per-linter: 0
29-
30-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
31-
max-same-issues: 0
32-
4+
version: "2"
5+
run:
6+
concurrency: 4
7+
issues-exit-code: 1
8+
tests: true
9+
output:
10+
formats:
11+
text:
12+
path: stdout
13+
print-linter-name: true
14+
print-issued-lines: true
3315
linters:
34-
disable-all: true
16+
default: none
3517
enable:
3618
- errcheck
37-
- goimports
38-
- gosimple
3919
- govet
4020
- ineffassign
4121
- staticcheck
4222
- unconvert
4323
- unused
44-
fast: true
45-
46-
# options for analysis running
47-
run:
48-
# default concurrency is a available CPU number
49-
concurrency: 4
50-
51-
# timeout for analysis, e.g. 30s, 5m, default is 1m
52-
timeout: 10m
53-
54-
# exit code when at least one issue was found, default is 1
55-
issues-exit-code: 1
56-
57-
# include test files or not, default is true
58-
tests: true
59-
60-
# list of build tags, all linters use it. Default is empty list.
61-
#build-tags:
62-
# - mytag
63-
64-
# which dirs to skip: issues from them won't be reported;
65-
# can use regexp here: generated.*, regexp is applied on full path;
66-
# default value is empty list, but default dirs are skipped independently
67-
# from this option's value (see skip-dirs-use-default).
68-
#skip-dirs:
69-
# - src/external_libs
70-
# - autogenerated_by_my_lib
71-
72-
# default is true. Enables skipping of directories:
73-
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
74-
skip-dirs-use-default: true
75-
76-
# which files to skip: they will be analyzed, but issues from them
77-
# won't be reported. Default value is empty list, but there is
78-
# no need to include all autogenerated files, we confidently recognize
79-
# autogenerated files. If it's not please let us know.
80-
exclude-files:
81-
- ".*\\.hcl2spec\\.go$"
82-
# - lib/bad.go
83-
84-
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
85-
# If invoked with -mod=readonly, the go command is disallowed from the implicit
86-
# automatic updating of go.mod described above. Instead, it fails when any changes
87-
# to go.mod are needed. This setting is most useful to check that go.mod does
88-
# not need updates, such as in a continuous integration and testing system.
89-
# If invoked with -mod=vendor, the go command assumes that the vendor
90-
# directory holds the correct copies of dependencies and ignores
91-
# the dependency descriptions in go.mod.
92-
# modules-download-mode: vendor
93-
94-
95-
# output configuration options
96-
output:
97-
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
98-
formats: colored-line-number
99-
100-
# print lines of code with issue, default is true
101-
print-issued-lines: true
102-
103-
# print linter name in the end of issue text, default is true
104-
print-linter-name: true
105-
106-
# make issues output unique by line, default is true
24+
settings:
25+
errcheck:
26+
check-type-assertions: false
27+
check-blank: false
28+
exclude-functions:
29+
- fmt:.*
30+
- io/ioutil:^Read.*
31+
- io:Close
32+
exclusions:
33+
generated: lax
34+
presets:
35+
- comments
36+
- common-false-positives
37+
- legacy
38+
- std-error-handling
39+
rules:
40+
- linters:
41+
- staticcheck
42+
text: S(1002|1008|1021)
43+
- linters:
44+
- staticcheck
45+
text: 'SA(1006|1019|4006|4010|4017|5007|6005|9004):'
46+
- linters:
47+
- lll
48+
source: '^//go:generate '
49+
- linters:
50+
- errcheck
51+
path: .*_test.go
52+
paths:
53+
- .*\.hcl2spec\.go$
54+
- third_party$
55+
- builtin$
56+
- examples$
57+
issues:
58+
max-issues-per-linter: 0
59+
max-same-issues: 0
10760
uniq-by-line: true
108-
109-
110-
# all available settings of specific linters
111-
linters-settings:
112-
errcheck:
113-
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
114-
# default is false: such cases aren't reported by default.
115-
check-type-assertions: false
116-
117-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
118-
# default is false: such cases aren't reported by default.
119-
check-blank: false
120-
121-
# [deprecated] comma-separated list of pairs of the form pkg:regex
122-
# the regex is used to ignore names within pkg. (default "fmt:.*").
123-
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
124-
exclude-functions: fmt:.*,io/ioutil:^Read.*,io:Close
125-
126-
# path to a file containing a list of functions to exclude from checking
127-
# see https://github.com/kisielk/errcheck#excluding-functions for details
128-
#exclude: /path/to/file.txt
61+
formatters:
62+
enable:
63+
- goimports
64+
exclusions:
65+
generated: lax
66+
paths:
67+
- .*\.hcl2spec\.go$
68+
- third_party$
69+
- builtin$
70+
- examples$

0 commit comments

Comments
 (0)