slicenilcmp
detects comparisons between slice and nil.
func f() {
var basicSlice []int
if basicSlice == nil { // want "suggestion: use len func for empty check"
print(basicSlice)
}
if len(basicSlice) == 0 { // ok
print(basicSlice)
}
}
$ go install github.com/replu/slicenilcmp/cmd/slicenilcmp@latest
$ go vet -vettool=$(which slicenilcmp) ./...