Documentation ¶
Index ¶
- Constants
- func AesDecrypt(ciphertext []byte, key []byte, iv []byte) ([]byte, error)
- func AesEncrypt(plaintext []byte, key []byte, iv []byte) ([]byte, error)
- func BitCount[V constraints.Unsigned](v V) int
- func Copy(dst, src interface{}) error
- func FileExist(path string) error
- func FilesExist(path ...string) error
- func FloatToString[R constraints.Float](v R, prec int) string
- func GetClientIp(r *http.Request) string
- func IntegerToString[R constraints.Integer](v R) string
- func Ip2Long(ipStr string) uint32
- func IsPublicIP(IP net.IP) bool
- func JoinFloat[T constraints.Float](s []T, sep string, prec int) string
- func JoinInt[T constraints.Signed](s []T, sep string) string
- func JoinUint[T constraints.Unsigned](s []T, sep string) string
- func Map2Slice[T, R any, K constraints.Ordered](s map[K]T, fn func(k K, v T) R) []R
- func Map2SliceFilter[T, R any, K constraints.Ordered](val map[K]T, get func(T) (R, bool)) []R
- func MapForEach[K constraints.Ordered, T any](val map[K]T, handle func(K) error) error
- func MapKeys[K constraints.Ordered, V any](m map[K]V) []K
- func MapMerge[K constraints.Ordered, V any](maps ...map[K]V) map[K]V
- func MapValues[K constraints.Ordered, V any](m map[K]V) []V
- func Md5(str string) string
- func NetLong2ip(ip uint32) string
- func ParseGzip(data []byte) ([]byte, error)
- func RandInt(min, max int) int
- func RandString(length int, chars string, mod uint8) string
- func RandStringEx(length int) string
- func Slice2Map[E any, K constraints.Ordered](s []E, fn func(v *E) K) map[K]*E
- func Slice2MapEx[T, V any, K constraints.Ordered](s []T, get func(*T) (K, V)) map[K]V
- func Slice2MapExFilter[T, V any, K constraints.Ordered](s []T, get func(*T) (K, V, bool)) map[K]V
- func Slice2MapFilter[E any, K constraints.Ordered](s []E, fn func(v *E) (K, bool)) map[K]*E
- func Slice2Slice[T, R any](arr []T, get func(*T) R) []R
- func Slice2SliceFilter[T, R any](arr []T, get func(*T) (R, bool)) []R
- func SliceDifference[E constraints.Ordered](sliceList ...[]E) []E
- func SliceForEach[T any](arr []T, handle func(T) bool) bool
- func SliceForEachIdx(l int, handle func(i int) bool) bool
- func SliceIntersect[E constraints.Ordered](sliceList ...[]E) []E
- func SliceSortAsc[T constraints.Ordered](v []T) []T
- func SliceSortDesc[T constraints.Ordered](v []T) []T
- func SliceUnion[E constraints.Ordered](sliceList ...[]E) []E
- func SliceUnique[E constraints.Ordered](v []E) []E
- func SplitFloat[T constraints.Float](s, sep string) ([]T, error)
- func SplitInt[T constraints.Signed](s, sep string) ([]T, error)
- func SplitSlice(v SplitSliceData, sHandle func(b, e int) error) error
- func SplitSliceEx(v SplitSliceData, sHandle func(b, e int) error, eHandle func(i int) error) error
- func SplitSliceTmp[T any](v []T, cHandle func(a, b *T) bool, sHandle func(b, e int) error) error
- func SplitSliceTmpEx[T any](v []T, cHandle func(a, b *T) bool, sHandle func(b, e int) error, ...) error
- func SplitUint[T constraints.Unsigned](s, sep string) ([]T, error)
- func StringMerge(str ...string) string
- func StringToFloat(v string) float64
- func StringToInteger(v string) int
- func SubStr(str string, start int, end int) string
- func TimeClearZero(v time.Time, mask uint16) time.Time
- func TimeFormatInLocation(tm time.Time, layout string) string
- func TimeIsLeapYear(year int) bool
- func TimeLatelyMonthDay(t time.Time, dd int, tl TimeLately, e bool) time.Time
- func TimeLatelyNMonthDay(t time.Time, dd int, n uint8, tl TimeLately, e bool) time.Time
- func TimeLatelyNWeekDay(t time.Time, w time.Weekday, n uint8, tl TimeLately, e bool) time.Time
- func TimeLatelyWeekDay(t time.Time, w time.Weekday, tl TimeLately, e bool) time.Time
- func TimeMonthDays(year int, month time.Month) int
- func TimeMonthDaysEx(t time.Time) int
- func TimeParseInLocation(tm, layout string) (time.Time, error)
- func TimeThisMonthDay(t time.Time, dd int) time.Time
- func TimeThisWeekDay(t time.Time, w time.Weekday) time.Time
- func ToFloat(val interface{}) float64
- func ToInt(val interface{}) int
- func ToString(val interface{}, limit ...int) string
- func VersionCompare(version1, version2, operator string) bool
- type EmptyStruct
- type JsonRawByte
- type JsonRawMarshalByte
- type JsonRawMarshalString
- type JsonRawString
- type JsonRawUnmarshalByte
- type JsonRawUnmarshalString
- type Map4Any
- type ParallelErrorHandle
- type ParallelFailType
- type ParallelFunc
- type ParallelHandle
- type ParallelHttpNewRequest
- type ParallelHttpResponseFormat
- type ParallelMgt
- func (r *ParallelMgt) AddFunc(handle ParallelFunc) int
- func (r *ParallelMgt) AddHandles(handle ParallelHandle, errHandle ParallelErrorHandle) int
- func (r *ParallelMgt) AddHttpRequest(client *http.Client, newReqHandler ParallelHttpNewRequest, ...) int
- func (r *ParallelMgt) Run(timeout time.Duration, failType ParallelFailType) []error
- type Set
- type SplitSliceData
- type TimeLately
Constants ¶
const ( RandStrNumberMask = 0x01 RandStrUpperCaseMask = 0x02 RandStrLowerCaseMask = 0x04 )
const ( TimeFormatDateTime = "2006-01-02 15:04:05" TimeFormatDate = "2006-01-02" TimeFormatDateYearMonth = "2006-01" TimeFormatTime = "15:04:05" TimeFormatTimeHourMinute = "15:04" TimeFormatANSIC = time.ANSIC // "Mon Jan _2 15:04:05 2006" TimeFormatUnixDate = time.UnixDate // "Mon Jan _2 15:04:05 MST 2006" TimeFormatRubyDate = time.RubyDate // "Mon Jan 02 15:04:05 -0700 2006" TimeFormatRFC822 = time.RFC822 // "02 Jan 06 15:04 MST" TimeFormatRFC822Z = time.RFC822Z // "02 Jan 06 15:04 -0700" TimeFormatRFC850 = time.RFC850 // "Monday, 02-Jan-06 15:04:05 MST" TimeFormatRFC1123 = time.RFC1123 // "Mon, 02 Jan 2006 15:04:05 MST" TimeFormatRFC1123Z = time.RFC1123Z // "Mon, 02 Jan 2006 15:04:05 -0700" TimeFormatRFC3339 = time.RFC3339 // "2006-01-02T15:04:05Z07:00" TimeFormatRFC3339Nano = time.RFC3339Nano // "2006-01-02T15:04:05.999999999Z07:00" TimeFormatKitchen = time.Kitchen // "3:04PM" )
const ( TimeClearNSecondMask = 0x01 TimeClearSecondMask = 0x02 TimeClearMinuteMask = 0x04 TimeClearHourMask = 0x08 TimeClearSecond = TimeClearNSecondMask TimeClearMinute = TimeClearSecondMask | TimeClearSecond TimeClearHour = TimeClearMinuteMask | TimeClearMinute TimeClearTime = TimeClearHourMask | TimeClearHour )
Variables ¶
This section is empty.
Functions ¶
func BitCount ¶
func BitCount[V constraints.Unsigned](v V) int
func FilesExist ¶
func FloatToString ¶
func FloatToString[R constraints.Float](v R, prec int) string
func IntegerToString ¶
func IntegerToString[R constraints.Integer](v R) string
func JoinFloat ¶
func JoinFloat[T constraints.Float](s []T, sep string, prec int) string
JoinFloat join 浮点型
func Map2Slice ¶
func Map2Slice[T, R any, K constraints.Ordered](s map[K]T, fn func(k K, v T) R) []R
Map2Slice map 转 切片
func Map2SliceFilter ¶
func Map2SliceFilter[T, R any, K constraints.Ordered](val map[K]T, get func(T) (R, bool)) []R
Map2SliceFilter map 转 切片, 并过滤对应数据
func MapForEach ¶
func MapForEach[K constraints.Ordered, T any](val map[K]T, handle func(K) error) error
func MapMerge ¶ added in v0.1.6
func MapMerge[K constraints.Ordered, V any](maps ...map[K]V) map[K]V
MapMerge 多个 map merge
func RandStringEx ¶
func Slice2Map ¶
func Slice2Map[E any, K constraints.Ordered](s []E, fn func(v *E) K) map[K]*E
Slice2Map 切片 转 map
func Slice2MapEx ¶
func Slice2MapEx[T, V any, K constraints.Ordered](s []T, get func(*T) (K, V)) map[K]V
Slice2MapEx 切片 转 map
func Slice2MapExFilter ¶
func Slice2MapExFilter[T, V any, K constraints.Ordered](s []T, get func(*T) (K, V, bool)) map[K]V
Slice2MapExFilter 切片 转 map, 并过滤对应数据
func Slice2MapFilter ¶
func Slice2MapFilter[E any, K constraints.Ordered](s []E, fn func(v *E) (K, bool)) map[K]*E
Slice2MapFilter 切片 转 map, 并过滤对应数据
func Slice2SliceFilter ¶
Slice2SliceFilter 切片 转 切片, 并过滤对应数据
func SliceDifference ¶
func SliceDifference[E constraints.Ordered](sliceList ...[]E) []E
SliceDifference 切片差集
func SliceForEachIdx ¶
SliceForEachIdx 切片遍历
func SliceIntersect ¶
func SliceIntersect[E constraints.Ordered](sliceList ...[]E) []E
SliceIntersect 切片交集
func SplitFloat ¶
func SplitFloat[T constraints.Float](s, sep string) ([]T, error)
SplitFloat split 切割 float
func SplitInt ¶
func SplitInt[T constraints.Signed](s, sep string) ([]T, error)
SplitInt split 切割 int
func SplitSlice ¶
func SplitSlice(v SplitSliceData, sHandle func(b, e int) error) error
SplitSlice split 切割 slice
func SplitSliceEx ¶
SplitSliceEx split 切割 slice
func SplitSliceTmp ¶ added in v0.1.3
SplitSliceTmp split 切割 slice
func SplitSliceTmpEx ¶ added in v0.1.3
func SplitSliceTmpEx[T any](v []T, cHandle func(a, b *T) bool, sHandle func(b, e int) error, eHandle func(i int) error) error
SplitSliceTmpEx split 切割 slice
func SplitUint ¶
func SplitUint[T constraints.Unsigned](s, sep string) ([]T, error)
SplitUint split 切割 uint
func StringMerge ¶
func StringToFloat ¶
func StringToInteger ¶
func TimeIsLeapYear ¶ added in v0.1.3
func TimeLatelyMonthDay ¶ added in v0.1.3
TimeLatelyMonthDay 获取最近一个月的指定日的日期, day 值为 -1 时候表示最后一天
func TimeLatelyNMonthDay ¶ added in v0.1.6
TimeLatelyNMonthDay 获取最近 n 个月的指定日的日期, day 值为 -1 时候表示最后一天
func TimeLatelyNWeekDay ¶ added in v0.1.6
TimeLatelyNWeekDay 获取最近 n 个周的指定周的日期, e 只有在 tl 值为 TimeLatelyBefore 和 TimeLatelyAfter 有效。
func TimeLatelyWeekDay ¶ added in v0.1.3
TimeLatelyWeekDay 获取最近一个周的指定周的日期, e 只有在 tl 值为 TimeLatelyBefore 和 TimeLatelyAfter 有效。
func TimeMonthDaysEx ¶ added in v0.1.6
func TimeThisMonthDay ¶ added in v0.1.6
TimeThisMonthDay 获取本月的指定周的日期
func TimeThisWeekDay ¶ added in v0.1.6
TimeThisWeekDay 获取本一个周的指定周的日期
Types ¶
type EmptyStruct ¶
type EmptyStruct struct{}
type JsonRawByte ¶ added in v0.1.4
type JsonRawByte []byte
func (JsonRawByte) MarshalJSON ¶ added in v0.1.4
func (v JsonRawByte) MarshalJSON() ([]byte, error)
func (*JsonRawByte) Set ¶ added in v0.1.4
func (v *JsonRawByte) Set(val string)
func (*JsonRawByte) String ¶ added in v0.1.4
func (v *JsonRawByte) String() string
func (*JsonRawByte) UnmarshalJSON ¶ added in v0.1.4
func (v *JsonRawByte) UnmarshalJSON(bytes []byte) error
type JsonRawMarshalByte ¶ added in v0.1.4
type JsonRawMarshalByte []byte
func (JsonRawMarshalByte) MarshalJSON ¶ added in v0.1.4
func (v JsonRawMarshalByte) MarshalJSON() ([]byte, error)
func (*JsonRawMarshalByte) Set ¶ added in v0.1.4
func (v *JsonRawMarshalByte) Set(val string)
type JsonRawMarshalString ¶ added in v0.1.4
type JsonRawMarshalString string
func (JsonRawMarshalString) MarshalJSON ¶ added in v0.1.4
func (v JsonRawMarshalString) MarshalJSON() ([]byte, error)
type JsonRawString ¶ added in v0.1.4
type JsonRawString string
func (JsonRawString) MarshalJSON ¶ added in v0.1.4
func (v JsonRawString) MarshalJSON() ([]byte, error)
func (*JsonRawString) UnmarshalJSON ¶ added in v0.1.4
func (v *JsonRawString) UnmarshalJSON(bytes []byte) error
type JsonRawUnmarshalByte ¶ added in v0.1.4
type JsonRawUnmarshalByte []byte
func (*JsonRawUnmarshalByte) String ¶ added in v0.1.4
func (v *JsonRawUnmarshalByte) String() string
func (*JsonRawUnmarshalByte) UnmarshalJSON ¶ added in v0.1.4
func (v *JsonRawUnmarshalByte) UnmarshalJSON(bytes []byte) error
type JsonRawUnmarshalString ¶
type JsonRawUnmarshalString string
func (*JsonRawUnmarshalString) UnmarshalJSON ¶
func (s *JsonRawUnmarshalString) UnmarshalJSON(bytes []byte) error
type ParallelErrorHandle ¶ added in v0.1.3
type ParallelErrorHandle func(err error)
type ParallelFailType ¶ added in v0.1.3
type ParallelFailType uint8
const ( ParallelFailTypeAll ParallelFailType = 1 ParallelFailTypeOne ParallelFailType = 2 )
type ParallelFunc ¶ added in v0.1.3
type ParallelFunc func() error
type ParallelHandle ¶ added in v0.1.3
func ParallelGetFunc ¶ added in v0.1.3
func ParallelGetFunc(handle ParallelFunc) ParallelHandle
func ParallelGetHttpRequest ¶ added in v0.1.3
func ParallelGetHttpRequest(client *http.Client, newReqHandler ParallelHttpNewRequest, reqFormatHandler ParallelHttpResponseFormat) ParallelHandle
type ParallelHttpNewRequest ¶ added in v0.1.3
type ParallelHttpResponseFormat ¶ added in v0.1.3
type ParallelHttpResponseFormat func(io.ReadCloser) error
type ParallelMgt ¶ added in v0.1.3
type ParallelMgt struct {
// contains filtered or unexported fields
}
func (*ParallelMgt) AddFunc ¶ added in v0.1.3
func (r *ParallelMgt) AddFunc(handle ParallelFunc) int
func (*ParallelMgt) AddHandles ¶ added in v0.1.3
func (r *ParallelMgt) AddHandles(handle ParallelHandle, errHandle ParallelErrorHandle) int
AddHandles @handle 需要处理 cancelCtx 事件
func (*ParallelMgt) AddHttpRequest ¶ added in v0.1.3
func (r *ParallelMgt) AddHttpRequest(client *http.Client, newReqHandler ParallelHttpNewRequest, reqFormatHandler ParallelHttpResponseFormat) int
func (*ParallelMgt) Run ¶ added in v0.1.3
func (r *ParallelMgt) Run(timeout time.Duration, failType ParallelFailType) []error
type Set ¶
type Set[T constraints.Ordered] map[T]EmptyStruct
func Slice2Set ¶
func Slice2Set[E any, K constraints.Ordered](s []E, fn func(v *E) K) Set[K]
Slice2Set 切片结构体转换为 map[结构体Field]struct{}
func Slice2SetFilter ¶
func Slice2SetFilter[E any, K constraints.Ordered](s []E, fn func(v *E) (K, bool)) Set[K]
Slice2SetFilter 切片结构体转换为 map[结构体Field]struct{}
type SplitSliceData ¶
SplitSliceData split 切割 slice 数据结构
type TimeLately ¶ added in v0.1.3
type TimeLately int
const ( TimeLatelyBefore TimeLately = 1 TimeLatelyAfter TimeLately = 2 )