Skip to content

Commit

Permalink
Adding prealloc linter rule (#35921)
Browse files Browse the repository at this point in the history
  • Loading branch information
amitkanfer authored Jun 28, 2023
1 parent 27763e8 commit 2a5bfb1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ linters:
- unconvert # Remove unnecessary type conversions
- wastedassign # wastedassign finds wasted assignment statements.
- gomodguard # check for blocked dependencies
- prealloc # Finds slice declarations that could potentially be pre-allocated

# all available settings of specific linters
linters-settings:
Expand Down Expand Up @@ -147,3 +148,18 @@ linters-settings:
- G401 # Detect the usage of DES, RC4, MD5 or SHA1: Used in non-crypto contexts.
- G501 # Import blocklist: crypto/md5: Used in non-crypto contexts.
- G505 # Import blocklist: crypto/sha1: Used in non-crypto contexts.

prealloc:
# IMPORTANT: we don't recommend using this linter before doing performance profiling.
# For most programs usage of prealloc will be a premature optimization.

# Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
# Default: true
simple: false
# Report pre-allocation suggestions on range loops.
# Default: true
range-loops: true
# Report pre-allocation suggestions on for loops.
# Default: false
for-loops: true

0 comments on commit 2a5bfb1

Please sign in to comment.