MCPcopy Index your code
hub / github.com/cortexlabs/cortex / InterfaceToStrStrMap

Function InterfaceToStrStrMap

pkg/lib/cast/interface.go:731–759  ·  view source on GitHub ↗
(in interface{})

Source from the content-addressed store, hash-verified

729}
730
731func InterfaceToStrStrMap(in interface{}) (map[string]string, bool) {
732 if in == nil {
733 return nil, true
734 }
735
736 if strMap, ok := in.(map[string]string); ok {
737 return strMap, true
738 }
739
740 inMap, ok := InterfaceToInterfaceInterfaceMap(in)
741 if !ok {
742 return nil, false
743 }
744
745 out := map[string]string{}
746
747 for key, value := range inMap {
748 castedKey, ok := key.(string)
749 if !ok {
750 return nil, false
751 }
752 castedVal, ok := value.(string)
753 if !ok {
754 return nil, false
755 }
756 out[castedKey] = castedVal
757 }
758 return out, true
759}
760
761func StrMapToStrInterfaceMap(in map[string]string) map[string]interface{} {
762 if in == nil {

Callers 1

StringMapFunction · 0.92

Calls 1

Tested by

no test coverage detected