github.com/kiali/kiali@v1.84.0/util/maps.go (about) 1 package util 2 3 func RemoveNilValues(root interface{}) { 4 if mRoot, isMap := root.(map[string]interface{}); isMap { 5 for k, v := range mRoot { 6 if v == nil { 7 delete(mRoot, k) 8 } 9 if leaf, isLeafMap := v.(map[string]interface{}); isLeafMap { 10 RemoveNilValues(leaf) 11 } 12 } 13 } 14 } 15 16 func CopyStringMap(originalMap map[string]string) map[string]string { 17 copyMap := make(map[string]string) 18 19 if len(originalMap) == 0 { 20 return copyMap 21 } 22 23 for key, value := range originalMap { 24 copyMap[key] = value 25 } 26 27 return copyMap 28 }