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

Function InterfaceToInterfaceSlice

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

Source from the content-addressed store, hash-verified

416}
417
418func InterfaceToInterfaceSlice(in interface{}) ([]interface{}, bool) {
419 if in == nil {
420 return nil, true
421 }
422
423 if inSlice, ok := in.([]interface{}); ok {
424 return inSlice, true
425 }
426
427 if reflect.TypeOf(in).Kind() != reflect.Slice {
428 return nil, false
429 }
430
431 inVal := reflect.ValueOf(in)
432 if inVal.IsNil() {
433 return nil, true
434 }
435
436 out := make([]interface{}, inVal.Len())
437 for i := 0; i < inVal.Len(); i++ {
438 out[i] = inVal.Index(i).Interface()
439 }
440 return out, true
441}
442
443func InterfaceToIntSlice(in interface{}) ([]int, bool) {
444 if in == nil {

Callers 15

checkNoCortexResourcesFunction · 0.92
checkOnlyCortexResourcesFunction · 0.92
FlattenAllStrValuesFunction · 0.92
StructListFunction · 0.92
InterfaceStructListFunction · 0.92
InterfaceToIntSliceFunction · 0.85
InterfaceToInt32SliceFunction · 0.85
InterfaceToInt64SliceFunction · 0.85
InterfaceToFloat32SliceFunction · 0.85
InterfaceToFloat64SliceFunction · 0.85
InterfaceToStrSliceFunction · 0.85

Calls 1

LenMethod · 0.45

Tested by 1