sirius/model/utils.go

23 lines
405 B
Go
Raw Normal View History

2023-04-14 09:01:18 +03:00
package model
2023-04-14 17:51:35 +03:00
func InterToArray(inp []interface{}) ([]int64, []bool, []string, []interface{}) {
2023-04-14 09:01:18 +03:00
var i []int64
var b []bool
var s []string
2023-04-14 17:51:35 +03:00
var a []interface{}
2023-04-14 09:01:18 +03:00
for _, v1 := range inp {
switch v2 := v1.(type) {
case float64:
i = append(i, int64(v2))
case bool:
b = append(b, bool(v2))
case string:
s = append(s, string(v2))
2023-04-14 17:51:35 +03:00
default:
a = append(a, v2)
2023-04-14 09:01:18 +03:00
}
}
2023-04-14 17:51:35 +03:00
return i, b, s, a
2023-04-14 09:01:18 +03:00
}