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 ByteSize(bytes uint64) string
- func Complete[E comparable](a []E, b []E) bool
- func Contain[E comparable](e E, es ...E) bool
- func CopyStructFields(a interface{}, b interface{}, fields ...string) (err error)
- func Delete[E any](es []E, index ...int) []E
- func DeleteAt[E any](es *[]E, index ...int) []E
- func Difference(slice1, slice2 []int64) []int64
- func DifferenceString(slice1, slice2 []string) []string
- 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 GenConversationIDForSingle(sendID, recvID string) string
- func GenConversationUniqueKeyForGroup(groupID string) string
- func GenConversationUniqueKeyForSingle(sendID, recvID string) string
- func GenGroupConversationID(groupID string) string
- func GenID() string
- func GenIDs(count int) []string
- func GenSmallImage(src, dst string) error
- func GetCurDayHalfTimeFormat() string
- func GetCurDayHalfTimestamp() int64
- func GetCurDayZeroTimeFormat() string
- func GetCurDayZeroTimestamp() int64
- func GetCurrentTimestampByMill() int64
- func GetCurrentTimestampByNano() int64
- func GetCurrentTimestampBySecond() int64
- func GetFuncName(skips ...int) string
- func GetHashCode(s string) uint32
- func GetLocalIP() (string, error)
- func GetMsgID(sendID string) string
- func GetNotificationConversationIDByConversationID(conversationID string) string
- func GetSelfFuncName() string
- func GetSelfNotificationConversationID(userID string) string
- func GetSeqsBeginEnd(seqs []int64) (int64, int64)
- 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 Int32ToString(i int32) string
- func Int64ToString(i int64) string
- func IntToString(i int) string
- func InterfaceArrayToStringArray(data []interface{}) (i []string)
- func Intersect(slice1, slice2 []int64) []int64
- func IntersectString(slice1, slice2 []string) []string
- func IsContain(target string, List []string) bool
- func IsContainInt(target int, List []int) bool
- func IsContainInt32(target int32, List []int32) bool
- func IsDir(path string) bool
- func IsDuplicateStringSlice(arr []string) bool
- func IsFile(path string) bool
- func JsonStringToMap(str string) (tempMap map[string]int32)
- func JsonStringToStruct(s string, args interface{}) error
- func Keys[K comparable, V any](kv map[K]V) []K
- func MapIntToJsonString(param map[string]int32) string
- func MapToJsonString(param map[string]interface{}) string
- func Max[E Ordered](e ...E) E
- func Md5(s string, salt ...string) string
- func Min[E Ordered](e ...E) E
- func MkDir(path string) error
- func NotNilReplace[T any](old, new_ *T)
- func OperationIDGenerator() string
- 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 RemoveDuplicate[T comparable](arr []T) []T
- func RemoveDuplicateElement(idList []string) []string
- 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 StringToInt(i string) int
- func StringToInt32(i string) int32
- func StringToInt64(i string) int64
- func StructToJsonBytes(param interface{}) []byte
- func StructToJsonString(param interface{}) 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 Uint32ToString(i uint32) string
- 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
- func WithMessage(err error, message string) error
- func Wrap(err error, message string) error
- func Wrap1(err error) error
- func Wrap2[T any](a T, err error) (T, error)
- func Wrap3[T any, V any](a T, b V, err error) (T, V, error)
- type Map
- func (m *Map) Del(key interface{})
- func (m *Map) Get(key interface{}) interface{}
- func (m *Map) Len() int
- func (m *Map) LockRange(f func(interface{}, interface{}))
- func (m *Map) RLockRange(f func(interface{}, interface{}))
- func (m *Map) Set(key interface{}, value interface{})
- func (m *Map) TestAndSet(key interface{}, value interface{}) interface{}
- func (m *Map) UnsafeDel(key interface{})
- func (m *Map) UnsafeGet(key interface{}) interface{}
- func (m *Map) UnsafeLen() int
- func (m *Map) UnsafeRange(f func(interface{}, interface{}))
- func (m *Map) UnsafeSet(key interface{}, value interface{})
- type Ordered
Constants ¶
const ( BYTE = 1 << (10 * iota) KILOBYTE MEGABYTE GIGABYTE TERABYTE PETABYTE EXABYTE )
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 CopyStructFields ¶
copy a by b b->a
func DifferenceString ¶
Get the diff of two slices
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 GenGroupConversationID ¶
func GenSmallImage ¶
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 GetFuncName ¶
func GetHashCode ¶
func GetLocalIP ¶
func GetSelfFuncName ¶
func GetSelfFuncName() string
func GetSeqsBeginEnd ¶
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 Int32ToString ¶
func Int64ToString ¶
func IntToString ¶
func InterfaceArrayToStringArray ¶
func InterfaceArrayToStringArray(data []interface{}) (i []string)
func IntersectString ¶
Get the intersection of two slices
func IsContainInt ¶
func IsContainInt32 ¶
func IsDuplicateStringSlice ¶
func JsonStringToMap ¶
func JsonStringToStruct ¶
The incoming parameter must be a pointer
func MapIntToJsonString ¶
func MapToJsonString ¶
func OperationIDGenerator ¶
func OperationIDGenerator() string
func OrderPtr ¶
func OrderPtr[E comparable, T any](es []E, ts *[]T, fn func(t T) E) []T
func RemoveDuplicate ¶
func RemoveDuplicate[T comparable](arr []T) []T
func RemoveDuplicateElement ¶
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 StringToInt ¶
func StringToInt32 ¶
func StringToInt64 ¶
func StructToJsonBytes ¶
func StructToJsonBytes(param interface{}) []byte
func StructToJsonString ¶
func StructToJsonString(param interface{}) string
func TimeToString ¶
func Uint32ToString ¶
func UniqueJoin ¶
func UnixMillSecondToTime ¶
func UnixNanoSecondToTime ¶
Convert nano timestamp to time.Time type
func UnixSecondToTime ¶
Convert timestamp to time.Time type
func WithMessage ¶
Types ¶
type Map ¶
func (*Map) RLockRange ¶
func (m *Map) RLockRange(f func(interface{}, interface{}))
func (*Map) TestAndSet ¶
func (m *Map) TestAndSet(key interface{}, value interface{}) interface{}
func (*Map) UnsafeRange ¶
func (m *Map) UnsafeRange(f func(interface{}, interface{}))