TEFXKZEDV324TIMEHVSYZY3SOZ5CKDA6E7II2N4CW3EV44JDTZOQC
package flatten
import (
"log"
)
func Flatten(input interface{}) []interface{} {
var ret []interface{}
in, ok := input.([]interface{})
if !ok {
log.Println("unable to convert ot []interface{}")
}
ret = flat(in)
if len(ret) == 0 {
return []interface{}{}
}
return ret
}
func flat(in []interface{}) []interface{} {
var ret []interface{}
for _, item := range in {
switch v := item.(type) {
case []interface{}:
ret = append(ret, flat(v)...)
case nil:
// do nothing
default:
ret = append(ret, item)
}
}
return ret
}