Documentation ¶
Index ¶
- func AnyOrDefault(val any, defVal any) any
- func Column[T any, V any](list []T, mapFn func(obj T) (val V, find bool)) []V
- func DecodeBools(quantity uint16, in []byte) (out []bool)
- func DurationOrDefault(val time.Duration, defVal time.Duration) time.Duration
- func EncodeBools(in []bool) (out []byte)
- func Filter[T any](ls []T, filter ...MatchFunc[T]) []T
- func GetBoolAt(b byte, pos uint) bool
- func IndexOf[T ~string | XintOrFloat](val T, list []T) int
- func IntOrDefault(val int, defVal int) int
- func Invoke(fn interface{}, types []interface{}, params ...interface{})
- func Map[T any, V any](list []T, mapFn MapFn[T, V]) []V
- func NumberToBytes(n any) []byte
- func NumberToBytesE(n any) ([]byte, error)
- func Remove[T Compared](ls []T, val T) []T
- func Reverse[T any](ls []T)
- func SetBoolAt(b byte, bitPos uint, data bool) byte
- func StrOrDefault(str string, defVal string) string
- func Unique[T ~string | XintOrFloat](list []T) []T
- type ComGroup
- type ComItem
- type Compared
- type Float
- type Int
- type IntOrFloat
- type Integer
- type MapFn
- type MatchFunc
- type Matcher
- type ScalarType
- type SimpleType
- type SortedType
- type StringHandleFunc
- type StringHandler
- type StringMatchFunc
- type StringMatcher
- type Uint
- type Xint
- type XintOrFloat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyOrDefault ¶
func DecodeBools ¶
DecodeBools Extract a specified number of Boolean values
func DurationOrDefault ¶
func EncodeBools ¶
EncodeBools Convert a boolean list to a byte array
func Filter ¶
Filter given slice, default will filter zero value.
Usage:
// output: [a, b] ss := arrutil.Filter([]string{"a", "", "b", ""})
func IndexOf ¶
func IndexOf[T ~string | XintOrFloat](val T, list []T) int
IndexOf value in given slice.
func IntOrDefault ¶
func Map ¶
Map a list to new list
eg: mapping [object0{},object1{},...] to flatten list [object0.someKey, object1.someKey, ...]
func NumberToBytes ¶
func NumberToBytesE ¶
func Remove ¶
func Remove[T Compared](ls []T, val T) []T
Remove give element from slice []T.
eg: []string{"site", "user", "info", "0"} -> []string{"site", "user", "info"}
func Reverse ¶
func Reverse[T any](ls []T)
Reverse any T slice.
eg: []string{"site", "user", "info", "0"} -> []string{"0", "info", "user", "site"}
func SetBoolAt ¶
SetBoolAt sets a boolean (bit) within a byte at bit position without changing the other bits it returns the resulted byte
func StrOrDefault ¶
func Unique ¶
func Unique[T ~string | XintOrFloat](list []T) []T
Unique value in the given slice data.
Types ¶
type ComItem ¶
type ComItem struct { // Index 数据索引 Index int // Index 原始数据大小 RawSize int // SplitOffset 分割点,即数据偏移索引 SplitOffset int // RipeSize 分割后的数据大小 RipeSize int // ExtraSize 额外需要的数据大小 ExtraSize int // Threshold 阀值 Threshold int }
func (*ComItem) TotalLength ¶
type IntOrFloat ¶
IntOrFloat interface type. all int and float types
type ScalarType ¶
ScalarType interface type.
TIP: has bool type, it cannot be ordered
contains: (x)int, float, ~string, ~bool types
type SimpleType ¶
SimpleType interface type. alias of ScalarType
contains: (x)int, float, ~string, ~bool types
type SortedType ¶
SortedType interface type. same of constraints.Ordered
it can be ordered, that supports the operators < <= >= >.
contains: (x)int, float, ~string types
type StringHandleFunc ¶
StringHandleFunc definition
func (StringHandleFunc) Handle ¶
func (fn StringHandleFunc) Handle(s string) string
Handle satisfies the StringHandler interface
type StringHandler ¶
StringHandler interface
type StringMatchFunc ¶
StringMatchFunc definition
func (StringMatchFunc) Match ¶
func (fn StringMatchFunc) Match(s string) bool
Match satisfies the StringMatcher interface
type XintOrFloat ¶
XintOrFloat interface type. all int, uint and float types