Skip to content

Commit a53fe83

Browse files
committed
docs: clarify depguard configuration
1 parent 019bde5 commit a53fe83

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

.golangci.next.reference.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,34 +367,42 @@ linters-settings:
367367
#
368368
# Variables:
369369
# - File Variables
370-
# you can still use and exclamation mark ! in front of a variable to say not to use it.
371-
# Example !$test will match any file that is not a go test file.
370+
# Use an exclamation mark `!` to negate a variable.
371+
# Example: `!$test` matches any file that is not a go test file.
372372
#
373373
# `$all` - matches all go files
374374
# `$test` - matches all go test files
375375
#
376376
# - Package Variables
377377
#
378-
# `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
378+
# `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
379379
#
380-
# Default: Only allow $gostd in all files.
380+
# Default (applies if no custom rules are defined): Only allow $gostd in all files.
381381
rules:
382382
# Name of a rule.
383383
main:
384-
# Used to determine the package matching priority.
385-
# There are three different modes: `original`, `strict`, and `lax`.
384+
# Defines package matching behavior. Available modes:
385+
# - `original`: allowed if it doesn't match the deny list and either matches the allow list or the allow list is empty.
386+
# - `strict`: allowed only if it matches the allow list and either doesn't match the deny list or the allow rule is more specific (longer) than the deny rule.
387+
# - `lax`: allowed if it doesn't match the deny list or the allow rule is more specific (longer) than the deny rule.
386388
# Default: "original"
387389
list-mode: lax
388390
# List of file globs that will match this list of settings to compare against.
389391
# Default: $all
390392
files:
391393
- "!**/*_a _file.go"
392394
# List of allowed packages.
395+
# Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
396+
# Default: []
393397
allow:
394398
- $gostd
395399
- github.com/OpenPeeDeeP
396-
# Packages that are not allowed where the value is a suggestion.
400+
# List of packages that are not allowed.
401+
# Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
402+
# Default: []
397403
deny:
404+
- pkg: "math/rand$"
405+
desc: use math/rand/v2
398406
- pkg: "github.com/sirupsen/logrus"
399407
desc: not allowed
400408
- pkg: "github.com/pkg/errors"

.golangci.reference.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,34 +367,42 @@ linters-settings:
367367
#
368368
# Variables:
369369
# - File Variables
370-
# you can still use and exclamation mark ! in front of a variable to say not to use it.
371-
# Example !$test will match any file that is not a go test file.
370+
# Use an exclamation mark `!` to negate a variable.
371+
# Example: `!$test` matches any file that is not a go test file.
372372
#
373373
# `$all` - matches all go files
374374
# `$test` - matches all go test files
375375
#
376376
# - Package Variables
377377
#
378-
# `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
378+
# `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
379379
#
380-
# Default: Only allow $gostd in all files.
380+
# Default (applies if no custom rules are defined): Only allow $gostd in all files.
381381
rules:
382382
# Name of a rule.
383383
main:
384-
# Used to determine the package matching priority.
385-
# There are three different modes: `original`, `strict`, and `lax`.
384+
# Defines package matching behavior. Available modes:
385+
# - `original`: allowed if it doesn't match the deny list and either matches the allow list or the allow list is empty.
386+
# - `strict`: allowed only if it matches the allow list and either doesn't match the deny list or the allow rule is more specific (longer) than the deny rule.
387+
# - `lax`: allowed if it doesn't match the deny list or the allow rule is more specific (longer) than the deny rule.
386388
# Default: "original"
387389
list-mode: lax
388390
# List of file globs that will match this list of settings to compare against.
389391
# Default: $all
390392
files:
391393
- "!**/*_a _file.go"
392394
# List of allowed packages.
395+
# Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
396+
# Default: []
393397
allow:
394398
- $gostd
395399
- github.com/OpenPeeDeeP
396-
# Packages that are not allowed where the value is a suggestion.
400+
# List of packages that are not allowed.
401+
# Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
402+
# Default: []
397403
deny:
404+
- pkg: "math/rand$"
405+
desc: use math/rand/v2
398406
- pkg: "github.com/sirupsen/logrus"
399407
desc: not allowed
400408
- pkg: "github.com/pkg/errors"

0 commit comments

Comments
 (0)