@@ -127,6 +127,7 @@ misspell: Finds commonly misspelled English words in comments [fast: true]
127127lll: Reports long lines [fast: true]
128128unparam: Reports unused function parameters [fast: false]
129129nakedret: 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]
130131```
131132
132133Pass ` -E/--enable ` to enable linter and ` -D/--disable ` to disable:
@@ -313,6 +314,7 @@ golangci-lint linters
313314- [ lll] ( https://github.com/walle/lll ) - Reports long lines
314315- [ unparam] ( https://github.com/mvdan/unparam ) - Reports unused function parameters
315316- [ 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
316318
317319# Configuration
318320The 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:
539541 nakedret :
540542 # make an issue if func has more lines of code than this setting and it has naked returns; default is 30
541543 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
542553
543554
544555linters :
@@ -547,7 +558,8 @@ linters:
547558 - govet
548559 enable-all : false
549560 disable :
550- maligned
561+ - maligned
562+ - prealloc
551563 disable-all : false
552564 presets :
553565 - bugs
@@ -620,6 +632,7 @@ linters:
620632 enable-all : true
621633 disable :
622634 - maligned
635+ - prealloc
623636` ` `
624637
625638# False Positives
@@ -726,6 +739,7 @@ There is the most valuable changes log:
7267391. Add support of the next linters :
727740 * unparam
728741 * misspell
742+ * prealloc
729743 * nakedret
730744 * lll
731745 * depguard
0 commit comments