gitlab.com/evatix-go/core@v1.3.55/converters/MapStringAnyToMapStringString.go (about) 1 package converters 2 3 import ( 4 "fmt" 5 6 "gitlab.com/evatix-go/core/constants" 7 ) 8 9 func MapStringAnyToMapStringString( 10 isSkipEmpty bool, 11 additionalMapItems map[string]interface{}, 12 ) map[string]string { 13 if len(additionalMapItems) == 0 { 14 return map[string]string{} 15 } 16 17 newMap := make(map[string]string, len(additionalMapItems)) 18 19 for key, valInf := range additionalMapItems { 20 val := fmt.Sprintf( 21 constants.SprintValueFormat, 22 valInf) 23 24 if isSkipEmpty && val == "" { 25 continue 26 } 27 28 newMap[key] = val 29 } 30 31 return newMap 32 } 33 34 func CloneMapStringStringPlusAppendMapStringAny( 35 isSkipEmpty bool, 36 mainMap map[string]interface{}, 37 additionalMapItems map[string]interface{}, 38 ) map[string]string { 39 if len(mainMap) == 0 && len(additionalMapItems) == 0 { 40 return map[string]string{} 41 } 42 43 newMap := make( 44 map[string]string, 45 len(mainMap)+ 46 len(additionalMapItems)+ 47 constants.Capacity3) 48 49 for key, valInf := range additionalMapItems { 50 val := fmt.Sprintf( 51 constants.SprintValueFormat, 52 valInf) 53 54 if isSkipEmpty && val == "" { 55 continue 56 } 57 58 newMap[key] = val 59 } 60 61 return newMap 62 }