github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/engine/wazevo/wazevoapi/resetmap.go (about) 1 package wazevoapi 2 3 // ResetMap resets the map to an empty state, or creates a new map if it is nil. 4 func ResetMap[K comparable, V any](m map[K]V) map[K]V { 5 if m == nil { 6 m = make(map[K]V) 7 } else { 8 for v := range m { 9 delete(m, v) 10 } 11 } 12 return m 13 }