Skip to content

Commit 05e3807

Browse files
committed
Update depguard configuration for golangci-lint v1.53
The depguard v2 linter allows different rules to be applied to different sets of files. See: golangci/golangci-lint#3795 See: https://github.com/OpenPeeDeeP/depguard#config See: https://golangci-lint.run/usage/linters/#depguard
1 parent 7c46037 commit 05e3807

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

.golangci.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,25 @@ linters:
2121

2222
linters-settings:
2323
depguard:
24-
include-go-root: true
25-
packages-with-error-message:
26-
- io/ioutil: >
27-
Use the "io" and "os" packages instead.
28-
See https://go.dev/doc/go1.16#ioutil
24+
rules:
25+
everything:
26+
deny:
27+
- pkg: io/ioutil
28+
desc: >
29+
Use the "io" and "os" packages instead.
30+
See https://go.dev/doc/go1.16#ioutil
2931
30-
- net/http/httptest: Should be used only in tests.
31-
- testing/*: The "testing" packages should be used only in tests.
32+
not-tests:
33+
files: ['!$test']
34+
deny:
35+
- pkg: net/http/httptest
36+
desc: Should be used only in tests.
3237

33-
- github.com/crunchydata/postgres-operator/internal/testing/*: >
34-
The "internal/testing" packages should be used only in tests.
38+
- pkg: testing/*
39+
desc: The "testing" packages should be used only in tests.
40+
41+
- pkg: github.com/crunchydata/postgres-operator/internal/testing/*
42+
desc: The "internal/testing" packages should be used only in tests.
3543

3644
exhaustive:
3745
default-signifies-exhaustive: true
@@ -60,14 +68,6 @@ linters-settings:
6068
alias: apierrors
6169
no-unaliased: true
6270

63-
issues:
64-
exclude-rules:
65-
# These testing packages are allowed in test files. The packages are
66-
# disallowed everywhere then ignored here because that is how depguard works.
67-
- linters: [depguard]
68-
path: _test[.]go$
69-
text: \`(net/http/httptest|[^`]*testing[^`]*)`
70-
7171
run:
7272
build-tags:
7373
- envtest

0 commit comments

Comments
 (0)