delete
SCC-S1033Calling delete on a nil
map does not
do anything (no-op), and it can be safely removed, or there is a potential bug
introduced with a typo.
func fn(m map[int]int) {
if _, ok := m[0]; ok {
delete(m, 0)
}
}
func fn(m map[int]int) {
delete(m, 0)
}
Using just delete
is the more idiomatic recommended version.