Skip to content

Commit 1b3464b

Browse files
mauri870mergify[bot]
authored andcommitted
chore: add linter that denies importing math/rand (#6650)
(cherry picked from commit cc84f9e)
1 parent 4507d47 commit 1b3464b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.golangci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ linters:
5454
- noctx # noctx finds sending http request without context.Context
5555
- unconvert # Remove unnecessary type conversions
5656
- wastedassign # wastedassign finds wasted assignment statements.
57-
- gomodguard # check for blocked dependencies
57+
- depguard # check for blocked imports from Go files
58+
- gomodguard # check for blocked imports from go.mod
5859
- gomoddirectives
5960

6061
# all available settings of specific linters
@@ -88,9 +89,9 @@ linters-settings:
8889
goimports:
8990
local-prefixes: github.com/elastic
9091

92+
# Check for blocked dependencies in go.mod.
9193
gomodguard:
9294
blocked:
93-
# List of blocked modules.
9495
modules:
9596
# Blocked module.
9697
- github.com/pkg/errors:
@@ -105,6 +106,15 @@ linters-settings:
105106
- github.com/gofrs/uuid/v5
106107
reason: "Use one uuid library consistently across the codebase"
107108

109+
# Check for blocked imports in Go files.
110+
depguard:
111+
rules:
112+
main:
113+
list-mode: lax
114+
deny:
115+
- pkg: "math/rand$"
116+
desc: "superseded by math/rand/v2"
117+
108118
gomoddirectives:
109119
# Forbid local `replace` directives
110120
replace-local: false

0 commit comments

Comments
 (0)