Request from coworkers:
Govet or lint could warn about appends to slices which were made with a length (but not
a capacity) and had no intervening mutations:
s := make([]Foo, len(m)) // accidental length; user meant capacity: make([]Foo, 0, len(m))
for k, v := range m {
....
s = append(s, foo)
}
The text was updated successfully, but these errors were encountered:
rsc
changed the title
cmd/govet: check for misused of append onto new, non-empty slice
x/tools/cmd/govet: check for misused of append onto new, non-empty slice
Apr 14, 2015
ALTree
changed the title
x/tools/cmd/govet: check for misused of append onto new, non-empty slice
cmd/vet: check for misused of append onto new, non-empty slice
Aug 10, 2017
The text was updated successfully, but these errors were encountered: