github.com/sagernet/sing@v0.4.0-beta.19.0.20240518125136-f67a0988a636/common/clear_compat.go (about) 1 //go:build !go1.21 2 3 package common 4 5 func ClearArray[T ~[]E, E any](t T) { 6 var defaultValue E 7 for i := range t { 8 t[i] = defaultValue 9 } 10 } 11 12 func ClearMap[T ~map[K]V, K comparable, V any](t T) { 13 for k := range t { 14 delete(t, k) 15 } 16 }