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

Function InterfaceToIntSlice

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

Source from the content-addressed store, hash-verified

441}
442
443func InterfaceToIntSlice(in interface{}) ([]int, bool) {
444 if in == nil {
445 return nil, true
446 }
447
448 if intSlice, ok := in.([]int); ok {
449 return intSlice, true
450 }
451
452 inSlice, ok := InterfaceToInterfaceSlice(in)
453 if !ok {
454 return nil, false
455 }
456 out := make([]int, len(inSlice))
457
458 for i, elem := range inSlice {
459 casted, ok := InterfaceToInt(elem)
460 if !ok {
461 return nil, false
462 }
463 out[i] = casted
464 }
465 return out, true
466}
467
468func InterfaceToInt32Slice(in interface{}) ([]int32, bool) {
469 if in == nil {

Callers 1

IntListFunction · 0.92

Calls 2

InterfaceToIntFunction · 0.85

Tested by

no test coverage detected