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

Function InterfaceToStrSlice

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

Source from the content-addressed store, hash-verified

566}
567
568func InterfaceToStrSlice(in interface{}) ([]string, bool) {
569 if in == nil {
570 return nil, true
571 }
572
573 if strSlice, ok := in.([]string); ok {
574 return strSlice, true
575 }
576
577 inSlice, ok := InterfaceToInterfaceSlice(in)
578 if !ok {
579 return nil, false
580 }
581
582 out := make([]string, len(inSlice))
583
584 for i, elem := range inSlice {
585 casted, ok := elem.(string)
586 if !ok {
587 return nil, false
588 }
589 out[i] = casted
590 }
591 return out, true
592}
593
594func InterfaceToBoolSlice(in interface{}) ([]bool, bool) {
595 if in == nil {

Callers 2

StringListFunction · 0.92

Calls 1

Tested by 1