-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
Description
I currently work in a team and we had a code issue a few times that made it beyond code review.
It is pre-allocating a slice with size instead of cap, then use append on it. Example
ar := make([]int, 10)
for i:=0; i<10; i++ {
ar = append(ar, i)
}
The correct pre-alloc would be ar := make([]int, 0, 10). Because of the missing 0,, the faulty code produces an array of size 20.
Would it be possible to add a check for this into your linter? I could not find any linter that has this check.
bunyk and alingse