gocapture
gocapture is a tool for detecting maps and slices that do not have sufficient length or capacity.
Instruction
go get github.com/sivchari/gocapture
Usage
package main
func main() {
// sufficient capacity
c := make([]int, 0, 5)
print(c)
// zero capacity
a := make([]int, 0)
print(a)
}
fish
go vet -vettool=(which gocapture) ./...
bash
go vet -vettool=`which gocapture` ./...
output
./main.go:9:19: captured the not capacity
CI
- run:
name: Install gocapture
command: go get github.com/sivchari/gocapture
- run:
name: Run gocapture
command: go vet -vettool=`which gocapture` ./...