@@ -127,6 +127,7 @@ misspell: Finds commonly misspelled English words in comments [fast: true]
127
127
lll: Reports long lines [fast: true]
128
128
unparam: Reports unused function parameters [fast: false]
129
129
nakedret: Finds naked returns in functions greater than a specified function length [fast: true]
130
+ prealloc: Finds slice declarations that could potentially be preallocated [fast: true]
130
131
```
131
132
132
133
Pass ` -E/--enable ` to enable linter and ` -D/--disable ` to disable:
@@ -313,6 +314,7 @@ golangci-lint linters
313
314
- [ lll] ( https://github.com/walle/lll ) - Reports long lines
314
315
- [ unparam] ( https://github.com/mvdan/unparam ) - Reports unused function parameters
315
316
- [ nakedret] ( https://github.com/alexkohler/nakedret ) - Finds naked returns in functions greater than a specified function length
317
+ - [ prealloc] ( https://github.com/alexkohler/prealloc ) - Finds slice declarations that could potentially be preallocated
316
318
317
319
# Configuration
318
320
The config file has lower priority than command-line options. If the same bool/string/int option is provided on the command-line
@@ -539,6 +541,15 @@ linters-settings:
539
541
nakedret :
540
542
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
541
543
max-func-lines : 30
544
+ prealloc :
545
+ # XXX: we don't recommend using this linter before doing performance profiling.
546
+ # For most programs usage of prealloc will be a premature optimization.
547
+
548
+ # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
549
+ # True by default.
550
+ simple : true
551
+ range-loops : true # Report preallocation suggestions on range loops, true by default
552
+ for-loops : false # Report preallocation suggestions on for loops, false by default
542
553
543
554
544
555
linters :
@@ -547,7 +558,8 @@ linters:
547
558
- govet
548
559
enable-all : false
549
560
disable :
550
- maligned
561
+ - maligned
562
+ - prealloc
551
563
disable-all : false
552
564
presets :
553
565
- bugs
@@ -620,6 +632,7 @@ linters:
620
632
enable-all : true
621
633
disable :
622
634
- maligned
635
+ - prealloc
623
636
` ` `
624
637
625
638
# False Positives
@@ -726,6 +739,7 @@ There is the most valuable changes log:
726
739
1. Add support of the next linters :
727
740
* unparam
728
741
* misspell
742
+ * prealloc
729
743
* nakedret
730
744
* lll
731
745
* depguard
0 commit comments