李伟乐 2 years ago
parent f1e9cf8b4a
commit d759f77ebd
  1. 15
      pkg/xstring/stringx.go

@ -611,3 +611,18 @@ func CoverInt64(str string) int64 {
i, _ := strconv.ParseInt(str, 10, 64) i, _ := strconv.ParseInt(str, 10, 64)
return i 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
}

Loading…
Cancel
Save