Skip to content

Commit 8876b68

Browse files
committed
golangci-lint: add hints for error wrapping
Wrapping errors may or may not be the right thing to do (see https://go.dev/blog/go1.13-errors#whether-to-wrap and the discussion in kubernetes#123234). But developers should at least think about it, so let's emit linter hints for it: the golangci-lint config by default enables it for go-errorlint, just not the linter itself, so we just need to add it for the "hints" config. Direct error comparisons and assertions also get checked. Those are typically something that should be replaced by errors.Is and errors.As, but as the existing code often doesn't do that, let's also treat those as just hints.
1 parent 5909bd2 commit 8876b68

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

hack/golangci-hints.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ linters:
8484
- ginkgolinter
8585
- gocritic
8686
- govet
87+
- errorlint
8788
- ineffassign
8889
- logcheck
8990
- revive

hack/golangci.yaml.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ linters:
140140
- ginkgolinter
141141
- gocritic
142142
- govet
143+
{{- if .Hints}}
144+
- errorlint
145+
{{- end}}
143146
- ineffassign
144147
- logcheck
145148
- revive

0 commit comments

Comments
 (0)