mirror of
https://github.com/gohouse/gorose.git
synced 2025-12-24 12:47:55 +08:00
20 lines
349 B
Go
20 lines
349 B
Go
package builder
|
|
|
|
import "reflect"
|
|
|
|
func toSlice(arg any) []any {
|
|
ref := reflect.Indirect(reflect.ValueOf(arg))
|
|
var res []any
|
|
switch ref.Kind() {
|
|
case reflect.Slice:
|
|
l := ref.Len()
|
|
v := ref.Slice(0, l)
|
|
for i := 0; i < l; i++ {
|
|
res = append(res, v.Index(i).Interface())
|
|
}
|
|
default:
|
|
res = append(res, ref.Interface())
|
|
}
|
|
return res
|
|
}
|