diff --git a/pkg/xstring/stringx.go b/pkg/xstring/stringx.go index 18e6b2a..85f26b3 100644 --- a/pkg/xstring/stringx.go +++ b/pkg/xstring/stringx.go @@ -611,3 +611,18 @@ func CoverInt64(str string) int64 { i, _ := strconv.ParseInt(str, 10, 64) return i } + +func ToInterfaceSlice(slice interface{}) []interface{} { + s := reflect.ValueOf(slice) + if s.Kind() != reflect.Slice { + panic("InterfaceSlice() given a non-slice type") + } + + ret := make([]interface{}, s.Len()) + + for i := 0; i < s.Len(); i++ { + ret[i] = s.Index(i).Interface() + } + + return ret +}