utils

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(crypted, key []byte) ([]byte, error)

func AesEncrypt

func AesEncrypt(origData, key []byte) ([]byte, error)

func CleanUpfuncName

func CleanUpfuncName(funcName string) string

func CopyFile

func CopyFile(srcName string, dstName string) (written int64, err error)

func DifferenceSubset

func DifferenceSubset(mainSlice, subSlice []int64) []int64

Get the diff of two slices

func DifferenceSubsetString

func DifferenceSubsetString(mainSlice, subSlice []string) []string

func FileExist

func FileExist(filename string) bool

func FileTmpPath

func FileTmpPath(fullPath, dbPrefix string) string

func FirstLower

func FirstLower(s string) string

func GetConversationIDByGroupID

func GetConversationIDByGroupID(groupID string) string

func GetConversationIDByMsg

func GetConversationIDByMsg(msg *sdk_struct.MsgStruct) string
funcation GetConversationIDBySessionType(sourceID string, sessionType int) string {
	switch sessionType {
	case constant.SingleChatType:
		return "single_" + sourceID
	case constant.GroupChatType:
		return "group_" + sourceID
	case constant.SuperGroupChatType:
		return "super_group_" + sourceID
	case constant.NotificationChatType:
		return "notification_" + sourceID
	}
	return ""
}

func GetConversationTableName

func GetConversationTableName(conversationID string) string

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

func GetErrTableName

func GetErrTableName(conversationID string) string

func GetGroupIDForMinSeq

func GetGroupIDForMinSeq(groupID string) string

func GetMsgID

func GetMsgID(sendID string) string

func GetSelfFuncName

func GetSelfFuncName() string

func GetSwitchFromOptions

func GetSwitchFromOptions(Options map[string]bool, key string) (result bool)

func GetTableName

func GetTableName(conversationID string) string

func GetUserIDForMinSeq

func GetUserIDForMinSeq(userID string) string

func Int32ToString

func Int32ToString(i int32) string

func Int64ToString

func Int64ToString(i int64) string

func IntToString

func IntToString(i int) string

func Intersect

func Intersect(slice1, slice2 []int64) []int64

Get the intersection of two slices

func IsContain

func IsContain(target string, List []string) bool

judge a string whether in the string list

func IsContainInt

func IsContainInt(target int, List []int) bool

func IsContainUInt32

func IsContainUInt32(target uint32, List []uint32) bool

func JsonDataOne

func JsonDataOne(pb proto.Message) map[string]interface{}

func JsonStringToStruct

func JsonStringToStruct(s string, args interface{}) error

The incoming parameter must be a pointer

func KMP

func KMP(rMainString string, rSubString string) (isInMainString bool)

* KMP *

func LogBegin

func LogBegin(v ...interface{})

func LogEnd

func LogEnd(v ...interface{})

func LogFReturn

func LogFReturn(v ...interface{})

func LogSReturn

func LogSReturn(v ...interface{})

func LogStart

func LogStart(v ...interface{})

func Md5

func Md5(s string) string

func OperationIDGenerator

func OperationIDGenerator() string

func PKCS5Padding

func PKCS5Padding(plaintext []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func ProtoToMap

func ProtoToMap(pb proto.Message, idFix bool) map[string]interface{}

func RemoveOneInList

func RemoveOneInList[T comparable](slice []T, val T) []T

func RemoveRepeatedElementsInList

func RemoveRepeatedElementsInList[T Comparable](slc []T) []T

func RunFuncName

func RunFuncName() string

func SetSwitchFromOptions

func SetSwitchFromOptions(Options map[string]bool, key string, value bool)

func StringToInt

func StringToInt(i string) int

func StringToInt64

func StringToInt64(i string) int64

func StructToJsonString

func StructToJsonString(param interface{}) string

func StructToJsonStringDefault

func StructToJsonStringDefault(param interface{}) string

func StructToMap

func StructToMap(user interface{}) map[string]interface{}

func TimeStringToTime

func TimeStringToTime(timeString string) (time.Time, error)

func TimeToString

func TimeToString(t time.Time) string

func TrimStringList

func TrimStringList(list []string) (result []string)

func Uint32ListConvert

func Uint32ListConvert(list []uint32) []int64

func UnixNanoSecondToTime

func UnixNanoSecondToTime(nanoSecond int64) time.Time

Convert nano timestamp to time.Time type

func UnixSecondToTime

func UnixSecondToTime(second int64) time.Time

func UnmarshalNotificationElem

func UnmarshalNotificationElem(bytes []byte, t interface{}) error

func Unwrap

func Unwrap(err error) error

func WithMessage

func WithMessage(err error, message string) error

func Wrap

func Wrap(err error, message string) error

Types

type Comparable

type Comparable interface {
	~int | ~string | ~float64 | ~int32
}

type LogInfo

type LogInfo struct {
	Info string `json:"info"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL