Documentation
¶
Index ¶
- Constants
- Variables
- func AesDecrypt(data []byte, key []byte) ([]byte, error)
- func AesEncrypt(data []byte, key []byte) ([]byte, error)
- func Base64Decode(data string) string
- func Base64Encode(data string) string
- func Batch[T any, V any](fn func(T) V, ts []T) []V
- func BothExist[E comparable](es ...[]E) []E
- func BothExistAny[E any, K comparable](es [][]E, fn func(e E) K) []E
- func Complete[E comparable](a []E, b []E) bool
- func Contain[E comparable](e E, es ...E) bool
- func Delete[E any](es []E, index ...int) []E
- func DeleteAt[E any](es *[]E, index ...int) []E
- func Distinct[T comparable](ts []T) []T
- func DistinctAny[E any, K comparable](es []E, fn func(e E) K) []E
- func DistinctAnyGetComparable[E any, K comparable](es []E, fn func(e E) K) []K
- func Duplicate[E comparable](es []E) bool
- func DuplicateAny[E any, K comparable](es []E, fn func(e E) K) bool
- func Equal[E comparable](a []E, b []E) bool
- func Filter[E, T any](es []E, fn func(e E) (T, bool)) []T
- func GetCurDayHalfTimeFormat() string
- func GetCurDayHalfTimestamp() int64
- func GetCurDayZeroTimeFormat() string
- func GetCurDayZeroTimestamp() int64
- func GetCurrentTimestampByMill() int64
- func GetCurrentTimestampByNano() int64
- func GetCurrentTimestampBySecond() int64
- func GetLocalIP() (string, error)
- func GetMsgID(sendID string) string
- func GetSwitchFromOptions(Options map[string]bool, key string) (result bool)
- func GetTimeStampByFormat(datetime string) string
- func HasKey[K comparable, V any](m map[K]V, k K) bool
- func If[T any](isa bool, a, b T) T
- func IndexAny[E any, K comparable](e E, es []E, fn func(e E) K) int
- func IndexOf[E comparable](e E, es ...E) int
- func InitMap[K comparable, V any](val *map[K]V)
- func InitSlice[T any](val *[]T)
- func Keys[K comparable, V any](kv map[K]V) []K
- func Max[E Ordered](e ...E) E
- func Md5(s string, salt ...string) string
- func Min[E Ordered](e ...E) E
- func NotNilReplace[T any](old, new_ *T)
- func Order[E comparable, T any](es []E, ts []T, fn func(t T) E) []T
- func OrderPtr[E comparable, T any](es []E, ts *[]T, fn func(t T) E) []T
- func Paginate[E any](es []E, pageNumber int, showNumber int) []E
- func SetSwitchFromOptions(options map[string]bool, key string, value bool)
- func Single[E comparable](a, b []E) []E
- func Slice[E any, T any](es []E, fn func(e E) T) []T
- func SliceAnySub[E any, T comparable](a, b []E, fn func(t E) T) []E
- func SliceSet[E comparable](es []E) map[E]struct{}
- func SliceSetAny[E any, K comparable](es []E, fn func(e E) K) map[K]struct{}
- func SliceSub[E comparable](a, b []E) []E
- func SliceSubAny[E comparable, T any](a []E, b []T, fn func(t T) E) []E
- func SliceToMap[E any, K comparable](es []E, fn func(e E) K) map[K]E
- func SliceToMapAny[E any, K comparable, V any](es []E, fn func(e E) (K, V)) map[K]V
- func SliceToMapOkAny[E any, K comparable, V any](es []E, fn func(e E) (K, V, bool)) map[K]V
- func Sort[E Ordered](es []E, asc bool) []E
- func SortAny[E any](es []E, fn func(a, b E) bool)
- func StructFieldNotNilReplace(dest, src any)
- func StructToJsonString(param any) string
- func TimeStringFormatTimeUnix(timeFormat string, timeSrc string) int64
- func TimeStringToTime(timeString string) (time.Time, error)
- func TimeToString(t time.Time) string
- func ToPtr[T any](t T) *T
- func UniqueJoin(s ...string) string
- func UnixMillSecondToTime(millSecond int64) time.Time
- func UnixNanoSecondToTime(nanoSecond int64) time.Time
- func UnixSecondToTime(second int64) time.Time
- func Unwrap(err error) error
- func Values[K comparable, V any](kv map[K]V) []V
- type Ordered
Constants ¶
const ( TimeOffset = 8 * 3600 //8 hour offset HalfOffset = 12 * 3600 //Half-day hourly offset )
Variables ¶
var ServerIP = ""
Functions ¶
func Base64Decode ¶
func Base64Encode ¶
func BothExistAny ¶
func BothExistAny[E any, K comparable](es [][]E, fn func(e E) K) []E
BothExistAny 获取切片中共同存在的元素(交集)
func DistinctAnyGetComparable ¶
func DistinctAnyGetComparable[E any, K comparable](es []E, fn func(e E) K) []K
func DuplicateAny ¶
func DuplicateAny[E any, K comparable](es []E, fn func(e E) K) bool
DuplicateAny 是否有重复的
func GetCurDayHalfTimeFormat ¶
func GetCurDayHalfTimeFormat() string
Get the formatted time at 12 o'clock of the day, the format is "2006-01-02_12-00-00"
func GetCurDayHalfTimestamp ¶
func GetCurDayHalfTimestamp() int64
Get the timestamp at 12 o'clock on the day
func GetCurDayZeroTimeFormat ¶
func GetCurDayZeroTimeFormat() string
Get the formatted time at 0 o'clock of the day, the format is "2006-01-02_00-00-00"
func GetCurDayZeroTimestamp ¶
func GetCurDayZeroTimestamp() int64
Get the timestamp at 0 o'clock of the day
func GetCurrentTimestampByMill ¶
func GetCurrentTimestampByMill() int64
Get the current timestamp by Mill
func GetCurrentTimestampByNano ¶
func GetCurrentTimestampByNano() int64
Get the current timestamp by Nano
func GetCurrentTimestampBySecond ¶
func GetCurrentTimestampBySecond() int64
Get the current timestamp by Second
func GetLocalIP ¶
func GetSwitchFromOptions ¶
func GetTimeStampByFormat ¶
func HasKey ¶
func HasKey[K comparable, V any](m map[K]V, k K) bool
HasKey get whether the map contains key
func IndexAny ¶
func IndexAny[E any, K comparable](e E, es []E, fn func(e E) K) int
IndexAny get the index of the element
func InitMap ¶
func InitMap[K comparable, V any](val *map[K]V)
func OrderPtr ¶
func OrderPtr[E comparable, T any](es []E, ts *[]T, fn func(t T) E) []T
func SetSwitchFromOptions ¶
func SliceAnySub ¶
func SliceAnySub[E any, T comparable](a, b []E, fn func(t E) T) []E
SliceAnySub a中存在,b中不存在 (a-b) fn 返回的是uuid
func SliceSetAny ¶
func SliceSetAny[E any, K comparable](es []E, fn func(e E) K) map[K]struct{}
SliceSetAny slice to map[K]struct{}
func SliceSubAny ¶
func SliceSubAny[E comparable, T any](a []E, b []T, fn func(t T) E) []E
SliceSubAny a中存在,b中不存在 (a-b)
func SliceToMap ¶
func SliceToMap[E any, K comparable](es []E, fn func(e E) K) map[K]E
SliceToMap slice to map
func SliceToMapAny ¶
func SliceToMapAny[E any, K comparable, V any](es []E, fn func(e E) (K, V)) map[K]V
SliceToMapAny slice to map (自定义类型)
func SliceToMapOkAny ¶
func SliceToMapOkAny[E any, K comparable, V any](es []E, fn func(e E) (K, V, bool)) map[K]V
SliceToMapOkAny slice to map (自定义类型, 筛选)
func StructFieldNotNilReplace ¶ added in v0.0.17
func StructFieldNotNilReplace(dest, src any)
func StructToJsonString ¶
func TimeToString ¶
func UniqueJoin ¶
func UnixMillSecondToTime ¶
func UnixNanoSecondToTime ¶
Convert nano timestamp to time.Time type
func UnixSecondToTime ¶
Convert timestamp to time.Time type