MCPcopy
hub / github.com/cortexlabs/cortex / InterfaceToInterfaceInterfaceMap

Function InterfaceToInterfaceInterfaceMap

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

Source from the content-addressed store, hash-verified

644}
645
646func InterfaceToInterfaceInterfaceMap(in interface{}) (map[interface{}]interface{}, bool) {
647 if in == nil {
648 return nil, true
649 }
650
651 if inMap, ok := in.(map[interface{}]interface{}); ok {
652 return inMap, true
653 }
654
655 if reflect.TypeOf(in).Kind() != reflect.Map {
656 return nil, false
657 }
658
659 inVal := reflect.ValueOf(in)
660 if inVal.IsNil() {
661 return nil, true
662 }
663
664 out := make(map[interface{}]interface{}, inVal.Len())
665 for _, key := range inVal.MapKeys() {
666 out[key.Interface()] = inVal.MapIndex(key).Interface()
667 }
668 return out, true
669}
670
671func InterfaceToStrInterfaceMap(in interface{}) (map[string]interface{}, bool) {
672 if in == nil {

Callers 7

checkNoCortexResourcesFunction · 0.92
checkOnlyCortexResourcesFunction · 0.92
validateInterfaceMapFunction · 0.92
JSONMarshallableFunction · 0.85
InterfaceToStrStrMapFunction · 0.85

Calls 1

LenMethod · 0.45

Tested by 1