func Test_toInt64Slice(t *testing.T) {
res, err := toInt64Slice([]int64{1})
fmt.Println(err, res)
}
func toInt64Slice(actual interface{}) ([]int64, error) {
var res []int64
value := reflect.ValueOf(actual)
if value.Kind() != reflect.Slice && value.Kind() != reflect.Array {
return nil, errors.New("parse error")
}
for i := 0; i < value.Len(); i++ {
res = append(res, value.Index(i).Interface().(int64))
}
return res ,nil
}
06-06
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交