Documentation ¶
Index ¶
- func Contains(a interface{}, match func(i int) bool) bool
- func ContainsAnyInt(a []int, find []int) bool
- func ContainsAnyInt32(a []int32, find []int32) bool
- func ContainsAnyInt64(a []int64, find []int64) bool
- func ContainsAnyString(a []string, find []string, ignoreCase ...bool) bool
- func ContainsInt(a []int, find int) bool
- func ContainsInt32(a []int32, find int32) bool
- func ContainsInt64(a []int64, find int64) bool
- func ContainsString(a []string, find string, ignoreCase ...bool) bool
- func ContainsStringF(a []string, f func(i int, str string) bool) bool
- func ContainsValue(slice interface{}, val interface{}, equal ...func(a, b interface{}) bool) bool
- func Count(slice interface{}, match func(i int) bool) int
- func DiffInt(src, dest []int) (matches, added, removed []int)
- func DiffInt64(src, dest []int64) (matches, added, removed []int64)
- func DiffString(src, dest []string, ignoreCase ...bool) (matches, added, removed []string)
- func DistinctInt(a []int) []int
- func DistinctInt32(a []int32) []int32
- func DistinctInt64(a []int64) []int64
- func DistinctSortedInt(a []int) []int
- func DistinctSortedInt32(a []int32) []int32
- func DistinctSortedInt64(a []int64) []int64
- func DistinctSortedString(a []string, ignoreCase ...bool) []string
- func DistinctString(a []string, ignoreCase ...bool) []string
- func Find(slice interface{}, match func(i int) bool, limit ...int) interface{}
- func FindInt(a []int, match func(i int, v int) bool, limit ...int) []int
- func FindInt64(a []int64, match func(i int, v int64) bool, limit ...int) []int64
- func FindN(slice interface{}, match func(i int) bool, limit int, offset ...int) interface{}
- func FindString(a []string, match func(i int, s string) bool, limit ...int) []string
- func First(slice interface{}, match func(i int) bool) (interface{}, bool)
- func FirstInt(a []int, match ...func(i int, v int) bool) (v int, ok bool)
- func FirstInt64(a []int64, match ...func(i int, v int64) bool) (v int64, ok bool)
- func FirstString(a []string, match ...func(i int, s string) bool) (s string, ok bool)
- func FloatToInt(a []float64) []int
- func FloatToInt64(a []float64) []int64
- func FloatToObj(a []float64) []interface{}
- func FloatToStr(a []float64) []string
- func IndexOf(a interface{}, match func(i int) bool) int
- func IndexOfAnyInt(a []int, find []int) int
- func IndexOfAnyInt32(a []int32, find []int32) int
- func IndexOfAnyInt64(a []int64, find []int64) int
- func IndexOfAnyString(a []string, find []string, ignoreCase ...bool) int
- func IndexOfInt(a []int, find int) int
- func IndexOfInt32(a []int32, find int32) int
- func IndexOfInt64(a []int64, find int64) int
- func IndexOfSortedInt(a []int, find int) int
- func IndexOfSortedInt64(a []int64, find int64) int
- func IndexOfSortedString(a []string, find string) int
- func IndexOfString(a []string, find string, ignoreCase ...bool) int
- func IndexOfStringF(a []string, f func(i int, str string) bool) int
- func IndexOfValue(slice interface{}, val interface{}, equal ...func(a, b interface{}) bool) int
- func Int64ToFloat(a []int64) []float64
- func Int64ToInt(a []int64) []int
- func Int64ToMap(arr []int64) map[int64]bool
- func Int64ToObj(a []int64) []interface{}
- func Int64ToStr(a []int64) []string
- func IntTo64(a []int) []int64
- func IntToFloat(a []int) []float64
- func IntToMap(arr []int) map[int]bool
- func IntToObj(a []int) []interface{}
- func IntToStr(a []int) []string
- func MustFirst(slice interface{}, match func(i int) bool) interface{}
- func MustFirstInt(a []int, match ...func(i int, v int) bool) (v int)
- func MustFirstInt64(a []int64, match ...func(i int, v int64) bool) (v int64)
- func MustFirstString(a []string, match ...func(i int, s string) bool) (s string)
- func MustShiftBool(a []bool, defaultVal ...bool) (out []bool, val bool)
- func MustShiftFloat(a []float64, defaultVal ...float64) (out []float64, val float64)
- func MustShiftInt(a []int, defaultVal ...int) (out []int, val int)
- func MustShiftInt64(a []int64, defaultVal ...int64) (out []int64, val int64)
- func MustShiftString(a []string, defaultVal ...string) (out []string, val string)
- func Remove(a interface{}, v interface{}) interface{}
- func RemoveAt(a interface{}, i ...int) interface{}
- func RemoveDuplicate(arr interface{}, f func(val interface{}) string) interface{}
- func RemoveIf(a interface{}, f func(i int) bool) interface{}
- func RemoveIfN(a interface{}, n int, f func(i int) bool) interface{}
- func RemoveInt(a []int, val ...int) []int
- func RemoveIntAt(a []int, i ...int) []int
- func RemoveIntIf(a []int, f func(i int) bool) []int
- func RemoveIntIfN(a []int, n int, f func(i int) bool) []int
- func RemoveIntN(a []int, n int, val ...int) []int
- func RemoveN(a interface{}, n int, v interface{}) interface{}
- func RemoveString(a []string, val ...string) []string
- func RemoveStringAt(a []string, i ...int) []string
- func RemoveStringIf(a []string, f func(i int) bool) []string
- func RemoveStringIfN(a []string, n int, f func(i int) bool) []string
- func RemoveStringN(a []string, n int, val ...string) []string
- func Repeat(a interface{}, n int, f ...func(i int, a interface{}) interface{}) interface{}
- func RepeatInt(a int, n int, f ...func(i int, a int) int) []int
- func RepeatString(a string, n int, f ...func(i int, s string) string) []string
- func ShiftBool(a []bool) (out []bool, val bool, ok bool)
- func ShiftFloat(a []float64) (out []float64, val float64, ok bool)
- func ShiftInt(a []int) (out []int, val int, ok bool)
- func ShiftInt64(a []int64) (out []int64, val int64, ok bool)
- func ShiftString(a []string) (out []string, val string, ok bool)
- func StrToFloat(a []string, ignoreErr ...bool) ([]float64, error)
- func StrToFloatNoErr(a []string, ignoreErr ...bool) []float64
- func StrToInt(a []string) ([]int, error)
- func StrToInt64(a []string) ([]int64, error)
- func StrToInt64NoErr(a []string) []int64
- func StrToIntNoErr(a []string) []int
- func StrToMap(arr []string) map[string]bool
- func StrToObj(a []string) []interface{}
- func ToBool(slice interface{}, f ...func(i int) (val bool, err error)) ([]bool, error)
- func ToBoolIf(slice interface{}, f func(i int) (val bool, ok bool, err error)) ([]bool, error)
- func ToBoolIfNoError(slice interface{}, f func(i int) (val bool, ok bool)) []bool
- func ToBoolNoError(slice interface{}, f ...func(i int) bool) []bool
- func ToFloat(slice interface{}, f ...func(i int) (val float64, err error)) ([]float64, error)
- func ToFloatIf(slice interface{}, f func(i int) (val float64, ok bool, err error)) ([]float64, error)
- func ToFloatIfNoError(slice interface{}, f func(i int) (val float64, ok bool)) []float64
- func ToFloatNoError(slice interface{}, f ...func(i int) float64) []float64
- func ToInt(slice interface{}, f ...func(i int) (val int, err error)) ([]int, error)
- func ToInt32(slice interface{}, f ...func(i int) (val int32, err error)) ([]int32, error)
- func ToInt32If(slice interface{}, f func(i int) (val int32, ok bool, err error)) ([]int32, error)
- func ToInt32IfNoError(slice interface{}, f func(i int) (val int32, ok bool)) []int32
- func ToInt32NoError(slice interface{}, f ...func(i int) int32) []int32
- func ToInt64(slice interface{}, f ...func(i int) (val int64, err error)) ([]int64, error)
- func ToInt64If(slice interface{}, f func(i int) (val int64, ok bool, err error)) ([]int64, error)
- func ToInt64IfNoError(slice interface{}, f func(i int) (val int64, ok bool)) []int64
- func ToInt64NoError(slice interface{}, f ...func(i int) int64) []int64
- func ToIntIf(slice interface{}, f func(i int) (val int, ok bool, err error)) ([]int, error)
- func ToIntIfNoError(slice interface{}, f func(i int) (val int, ok bool)) []int
- func ToIntNoError(slice interface{}, f ...func(i int) int) []int
- func ToInterface(slice interface{}, f ...func(a interface{}) interface{}) []interface{}
- func ToSlice(slice interface{}, f ...func(a interface{}) interface{}) []interface{}
- func ToStr(slice interface{}, f ...func(i int) (val string, err error)) ([]string, error)
- func ToStrIf(slice interface{}, f func(i int) (val string, ok bool, err error)) ([]string, error)
- func ToStrIfNoError(slice interface{}, f func(i int) (val string, ok bool)) []string
- func ToStrNoError(slice interface{}, f ...func(i int) string) []string
- func ToType(slice interface{}, dstElemType reflect.Type, ...) interface{}
- func UnionInt(a ...[]int) []int
- func UnionInt32(a ...[]int32) []int32
- func UnionInt64(a ...[]int64) []int64
- func UnionString(a, b []string, ignoreCase ...bool) []string
- type CommaSepInt
- type CommaSepString
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsAnyInt ¶
func ContainsAnyInt32 ¶
func ContainsAnyInt64 ¶
func ContainsInt ¶
func ContainsInt32 ¶
func ContainsInt64 ¶
func ContainsValue ¶
func DiffString ¶
func DistinctInt ¶
func DistinctInt32 ¶
func DistinctInt64 ¶
func DistinctSortedInt ¶
func DistinctSortedInt32 ¶
func DistinctSortedInt64 ¶
func DistinctSortedString ¶
func DistinctString ¶
func FindString ¶
func FirstString ¶
func FloatToInt ¶
func FloatToInt64 ¶
func FloatToObj ¶
func FloatToObj(a []float64) []interface{}
func FloatToStr ¶
func IndexOfAnyString ¶
获取指定值在数组中的索引。-1 表示不在数组中
func IndexOfSortedInt ¶
获取指定值在有序数组中的索引。-1 表示不在数组中。数组必须是升序排序的
func IndexOfSortedInt64 ¶
获取指定值在有序数组中的索引。-1 表示不在数组中。数组必须是升序排序的
func IndexOfSortedString ¶
获取指定值在有序数组中的索引。-1 表示不在数组中。数组必须是升序排序的
func IndexOfString ¶
获取指定值在数组中的索引。-1 表示不在数组中
func IndexOfStringF ¶
获取指定值在数组中的索引。-1 表示不在数组中
func IndexOfValue ¶
func Int64ToFloat ¶
func Int64ToInt ¶
func Int64ToMap ¶
func Int64ToObj ¶
func Int64ToObj(a []int64) []interface{}
func Int64ToStr ¶
func IntToFloat ¶
func MustFirstString ¶
func MustShiftFloat ¶
func MustShiftString ¶
func RemoveDuplicate ¶
func RemoveDuplicate(arr interface{}, f func(val interface{}) string) interface{}
func RemoveIntAt ¶
func RemoveString ¶
func RemoveStringAt ¶
func StrToFloatNoErr ¶
func StrToInt64 ¶
func StrToInt64NoErr ¶
func StrToIntNoErr ¶
func ToBoolIfNoError ¶
func ToBoolNoError ¶
func ToFloatIf ¶
func ToFloatIf(slice interface{}, f func(i int) (val float64, ok bool, err error)) ([]float64, error)
将数组转换为 float64 数组
slice: 要转换的源,必须是切片类型 f: 过滤函数,返回值中的 ok 表示是否需要加入到结果数组中。
func ToFloatIfNoError ¶
func ToFloatNoError ¶
func ToInt32IfNoError ¶
func ToInt32NoError ¶
func ToInt64IfNoError ¶
func ToInt64NoError ¶
func ToIntIfNoError ¶
func ToIntNoError ¶
func ToInterface ¶
func ToInterface(slice interface{}, f ...func(a interface{}) interface{}) []interface{}
将数组转换为 interface 数组 参数:
slice: 要转换的源,必须是切片类型
func ToSlice ¶
func ToSlice(slice interface{}, f ...func(a interface{}) interface{}) []interface{}
将数组转换为 interface 数组 参数:
slice: 要转换的源,必须是切片类型
func ToStrIfNoError ¶
func ToStrNoError ¶
func ToType ¶
func ToType(slice interface{}, dstElemType reflect.Type, f ...func(a interface{}) interface{}) interface{}
将数组或切片转换为指定的切片类型。
参数:
a: 要转换的数组。 dstElemType: 目标元素的类型。 f: 转换时的自定义回调函数。
Example ¶
arr := make([]interface{}, 4) for i := range arr { arr[i] = int64(i) } // 下面代码将会 Panic,因为无法从 []interface{} 直接转换为 []int64,即使切片内的元素类型相同。 // intArr := arr.([]int64) // 通过 ToType(dstType=typeof(int64)) 可以实现转换。 intArr, _ := ToType(arr, reflect.TypeOf(int64(0))).([]int64) if len(arr) != len(intArr) { panic("length not equal") } for i := range intArr { if arr[i] != intArr[i] { panic(fmt.Sprintf("val[%v] not equal", i)) } }
Output:
Types ¶
type CommaSepInt ¶
type CommaSepInt []int
CommaSepInt 以逗号分隔的整数
func (*CommaSepInt) FromDB ¶
func (this *CommaSepInt) FromDB(bytes []byte) error
func (*CommaSepInt) FromString ¶
func (this *CommaSepInt) FromString(str string) error
func (CommaSepInt) String ¶
func (this CommaSepInt) String() string
func (*CommaSepInt) ToDB ¶
func (this *CommaSepInt) ToDB() ([]byte, error)
type CommaSepString ¶
type CommaSepString []string
以逗号分隔的 string
注意:
每个字符串元素中不能再包含逗号,否则会导致序列化与反序列化结果不一致
func (*CommaSepString) FromDB ¶
func (this *CommaSepString) FromDB(bytes []byte) error
func (*CommaSepString) FromString ¶
func (this *CommaSepString) FromString(str string) error
func (CommaSepString) String ¶
func (this CommaSepString) String() string
func (*CommaSepString) ToDB ¶
func (this *CommaSepString) ToDB() ([]byte, error)
Click to show internal directories.
Click to hide internal directories.