47
47
- " .*\\ .my\\ .go$"
48
48
- lib/bad.go
49
49
50
- # By default, it isn't set.
51
50
# If set we pass it to "go list -mod={option}". From "go help modules":
52
51
# If invoked with -mod=readonly, the go command is disallowed from the implicit
53
52
# automatic updating of go.mod described above. Instead, it fails when any changes
56
55
# If invoked with -mod=vendor, the go command assumes that the vendor
57
56
# directory holds the correct copies of dependencies and ignores
58
57
# the dependency descriptions in go.mod.
59
- modules-download-mode : readonly|vendor|mod
58
+ #
59
+ # Allowed values: readonly|vendor|mod
60
+ # By default, it isn't set.
61
+ modules-download-mode : readonly
60
62
61
63
# Allow multiple parallel golangci-lint instances running.
62
64
# If false (default) - golangci-lint acquires file lock on start.
@@ -143,13 +145,26 @@ linters-settings:
143
145
disable-dec-num-check : false
144
146
145
147
depguard :
146
- list-type : denylist
147
- include-go-root : false
148
+ # Kind of list is passed in.
149
+ # Allowed values: allowlist|denylist
150
+ # Default: denylist
151
+ list-type : allowlist
152
+
153
+ # Check the list against standard lib.
154
+ # Default: false
155
+ include-go-root : true
156
+
157
+ # A list of packages for the list type specified.
158
+ # Default: []
148
159
packages :
149
160
- github.com/sirupsen/logrus
161
+
162
+ # A list of packages for the list type specified.
163
+ # Specify an error message to output when a denied package is used.
164
+ # Default: []
150
165
packages-with-error-message :
151
- # Specify an error message to output when a denied package is used.
152
166
- github.com/sirupsen/logrus : ' logging is allowed only by logutils.Log'
167
+
153
168
# Create additional guards that follow the same configuration pattern.
154
169
# Results from all guards are aggregated together.
155
170
additional-guards :
@@ -226,23 +241,30 @@ linters-settings:
226
241
errorlint :
227
242
# Check whether fmt.Errorf uses the %w verb for formatting errors.
228
243
# See the https://github.com/polyfloyd/go-errorlint for caveats.
229
- errorf : true
244
+ # Default: true
245
+ errorf : false
230
246
# Check for plain type assertions and type switches.
231
- asserts : true
247
+ # Default: true
248
+ asserts : false
232
249
# Check for plain error comparisons.
233
- comparison : true
250
+ # Default: true
251
+ comparison : false
234
252
235
253
exhaustive :
236
254
# Check switch statements in generated files also.
237
- check-generated : false
255
+ # Default: false
256
+ check-generated : true
238
257
# Presence of "default" case in switch statements satisfies exhaustiveness,
239
258
# even if all enum members are not listed.
240
- default-signifies-exhaustive : false
259
+ # Default: false
260
+ default-signifies-exhaustive : true
241
261
# Enum members matching the supplied regex do not have to be listed in
242
262
# switch statements to satisfy exhaustiveness.
243
- ignore-enum-members : " "
263
+ # Default: ""
264
+ ignore-enum-members : " Example.+"
244
265
# Consider enums only in package scopes, not in inner scopes.
245
- package-scope-only : false
266
+ # Default: false
267
+ package-scope-only : true
246
268
247
269
exhaustivestruct :
248
270
# Struct Patterns is list of expressions to match struct packages and names.
@@ -263,8 +285,14 @@ linters-settings:
263
285
exclude_godoc_examples : false
264
286
265
287
funlen :
266
- lines : 60
267
- statements : 40
288
+ # Checks the number of lines in a function.
289
+ # If lower than 0, disable the check.
290
+ # Default: 60
291
+ lines : -1
292
+ # Checks the number of statements in a function.
293
+ # If lower than 0, disable the check.
294
+ # Default: 40
295
+ statements : -1
268
296
269
297
gci :
270
298
# Put imports beginning with prefix after 3rd-party packages.
@@ -274,7 +302,7 @@ linters-settings:
274
302
275
303
gocognit :
276
304
# Minimal code complexity to report
277
- # Default: 30, (but we recommend 10-20)
305
+ # Default: 30 (but we recommend 10-20)
278
306
min-complexity : 10
279
307
280
308
goconst :
@@ -323,9 +351,17 @@ linters-settings:
323
351
# See https://github.com/go-critic/go-critic#usage -> section "Tags".
324
352
# Default: []
325
353
enabled-tags :
354
+ - diagnostic
355
+ - style
326
356
- performance
357
+ - experimental
358
+ - opinionated
327
359
disabled-tags :
360
+ - diagnostic
361
+ - style
362
+ - performance
328
363
- experimental
364
+ - opinionated
329
365
330
366
# Settings passed to gocritic.
331
367
# The settings key is the name of a supported gocritic checker.
@@ -408,7 +444,7 @@ linters-settings:
408
444
409
445
gocyclo :
410
446
# Minimal code complexity to report.
411
- # Default: 30, (but we recommend 10-20)
447
+ # Default: 30 (but we recommend 10-20)
412
448
min-complexity : 10
413
449
414
450
godot :
@@ -444,23 +480,26 @@ linters-settings:
444
480
gofumpt :
445
481
# Select the Go version to target.
446
482
# Default: 1.15
447
- lang-version : " 1.15 "
483
+ lang-version : " 1.17 "
448
484
449
485
# Choose whether to use the extra rules.
450
486
# Default: false
451
487
extra-rules : true
452
488
453
489
goheader :
490
+ # Supports two types 'const` and `regexp`.
491
+ # Values can be used recursively.
454
492
values :
455
493
const :
456
494
# Define here const type values in format k:v.
457
495
# For example:
458
- # COMPANY: MY COMPANY
496
+ COMPANY : MY COMPANY
459
497
regexp :
460
498
# Define here regexp type values.
461
499
# for example:
462
- # AUTHOR: .*@mycompany\.com
463
- template : # |-
500
+ AUTHOR : .*@mycompany\.com
501
+ # The template use for checking.
502
+ template : |-
464
503
# Put here copyright header template for source code files
465
504
# For example:
466
505
# Note: {{ YEAR }} is a builtin value that returns the year relative to the current machine time.
@@ -479,8 +518,9 @@ linters-settings:
479
518
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
480
519
# See the License for the specific language governing permissions and
481
520
# limitations under the License.
482
- template-path :
483
- # Also, as alternative of directive 'template' you may put the path to file with the template source.
521
+ # As alternative of directive 'template', you may put the path to file with the template source.
522
+ # Useful if you need to load the template from a specific file.
523
+ template-path : /path/to/my/template.tmpl
484
524
485
525
goimports :
486
526
# Put imports beginning with prefix after 3rd-party packages.
@@ -575,18 +615,26 @@ linters-settings:
575
615
- G401
576
616
- G306
577
617
- G101
618
+
578
619
# To specify a set of rules to explicitly exclude.
579
620
# Available rules: https://github.com/securego/gosec#available-rules
580
621
excludes :
581
622
- G204
623
+
582
624
# Exclude generated files
625
+ # Default: false
583
626
exclude-generated : true
627
+
584
628
# Filter out the issues with a lower severity than the given value.
585
629
# Valid options are: low, medium, high.
586
- severity : " low"
630
+ # Default: low
631
+ severity : medium
632
+
587
633
# Filter out the issues with a lower confidence than the given value.
588
634
# Valid options are: low, medium, high.
589
- confidence : " low"
635
+ # Default: low
636
+ confidence : medium
637
+
590
638
# To specify the configuration of rules.
591
639
# The configuration of rules is not fully documented by gosec:
592
640
# https://github.com/securego/gosec#configuration
@@ -705,9 +753,11 @@ linters-settings:
705
753
ifshort :
706
754
# Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax.
707
755
# Has higher priority than max-decl-chars.
708
- max-decl-lines : 1
756
+ # Default: 1
757
+ max-decl-lines : 2
709
758
# Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
710
- max-decl-chars : 30
759
+ # Default: 30
760
+ max-decl-chars : 40
711
761
712
762
importas :
713
763
# Do not allow unaliased imports of aliased packages.
@@ -809,15 +859,16 @@ linters-settings:
809
859
nlreturn :
810
860
# Size of the block (including return statement that is still "OK")
811
861
# so no return split required.
812
- block-size : 1
862
+ # Default: 1
863
+ block-size : 2
813
864
814
865
nolintlint :
815
866
# Disable to ensure that all nolint directives actually have an effect.
816
867
# Default: false
817
- allow-unused : false
868
+ allow-unused : true
818
869
# Disable to ensure that nolint directives don't have a leading space.
819
870
# Default: true
820
- allow-leading-space : true
871
+ allow-leading-space : false
821
872
# Exclude following linters from requiring an explanation.
822
873
# Default: []
823
874
allow-no-explanation : [ ]
@@ -844,9 +895,11 @@ linters-settings:
844
895
845
896
predeclared :
846
897
# Comma-separated list of predeclared identifiers to not report on.
847
- ignore : " "
898
+ # Default: ""
899
+ ignore : " new,int"
848
900
# Include method names and field names (i.e., qualified names) in checks.
849
- q : false
901
+ # Default: false
902
+ q : true
850
903
851
904
promlinter :
852
905
# Promlinter cannot infer all metrics name in static analysis.
@@ -1172,13 +1225,15 @@ linters-settings:
1172
1225
- github.com/jmoiron/sqlx
1173
1226
1174
1227
staticcheck :
1175
- # Select the Go version to target. The default is '1.13'.
1228
+ # Select the Go version to target.
1229
+ # Default: 1.13
1176
1230
go : " 1.15"
1177
1231
# https://staticcheck.io/docs/options#checks
1178
1232
checks : [ "all" ]
1179
1233
1180
1234
stylecheck :
1181
- # Select the Go version to target. The default is '1.13'.
1235
+ # Select the Go version to target.
1236
+ # Default: 1.13
1182
1237
go : " 1.15"
1183
1238
# https://staticcheck.io/docs/options#checks
1184
1239
checks : [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ]
@@ -1244,6 +1299,7 @@ linters-settings:
1244
1299
1245
1300
varcheck :
1246
1301
# Check usage of exported fields and variables.
1302
+ # Default: false
1247
1303
exported-fields : true
1248
1304
1249
1305
varnamelen :
@@ -1288,9 +1344,11 @@ linters-settings:
1288
1344
1289
1345
whitespace :
1290
1346
# Enforces newlines (or comments) after every multi-line if statement.
1291
- multi-if : false
1347
+ # Default: false
1348
+ multi-if : true
1292
1349
# Enforces newlines (or comments) after every multi-line function signature.
1293
- multi-func : false
1350
+ # Default: false
1351
+ multi-func : true
1294
1352
1295
1353
wrapcheck :
1296
1354
# An array of strings that specify substrings of signatures to ignore.
@@ -1380,6 +1438,7 @@ linters-settings:
1380
1438
# Optional.
1381
1439
original-url : github.com/golangci/example-linter
1382
1440
1441
+
1383
1442
linters :
1384
1443
# Disable all linters.
1385
1444
disable-all : true
@@ -1662,6 +1721,7 @@ issues:
1662
1721
# Fix found issues (if it's supported by the linter).
1663
1722
fix : true
1664
1723
1724
+
1665
1725
severity :
1666
1726
# Set the default severity for issues.
1667
1727
#
0 commit comments