makezero
makezero copied to clipboard
A linter to ensure that slices are not initialized with non-zero length
Fix for https://github.com/ashanbrown/makezero/issues/12 it will still report the case below call append before copy, because the ast.Walk visit order, ``` out := make([]int, len(in)) out = append(out, 4) copy(out, in)...
Related to #13 I bumped the version of x/tools because without it I was getting an error "internal error: package "math" without types was imported from [xxx]". (I'm using golang...
Hi 🙂 Please, bump `golang.org/x/tools` to v0.7.0 (as minimum) and make new tag in your repo. It's important to be consistent with new Go 1.20 **golangci-lint.** Related to https://github.com/golangci/golangci-lint/issues/3086 Thanks!...
if we have the following situation ```go func someFunc() { slice1 := []int{1, 2, 3} slice2 := make([]int, len(slice1)) copy(slice2, slice1) slice2 = append(slice2, 4) } ``` The linter will...
A bad append could happen in another function. This is probably why it's best to just never initialize a non-empty slice.