Documentation
¶
Index ¶
- func AddTime(unit string, quantity int64, baseTime ...time.Time) time.Time
- func CalculateNextResetTime(expireTime int64, resetCycle int32) int64
- func CloneMapToStruct(input any, output interface{}) error
- func Contains[T comparable](slice []T, target T) bool
- func ConvertValueToString(value reflect.Value) string
- func Curve25519Genkey(StdEncoding bool, inputBase64 string) (public, private string, err error)
- func DayDiff(startTime, endTime time.Time) int64
- func DaysToMonthDay(t time.Time, targetDay int) int64
- func DaysToNextMonth(t time.Time) int64
- func DaysToYearDay(t time.Time, month int, day int) int64
- func DeepCopy[T, K any](destStruct T, srcStruct K, opts ...CopyOption) T
- func EncodeBase36(id int64) string
- func EncodePassWord(str string) string
- func ExtractVersionNumber(versionStr string) int
- func FixedUniqueString(s string, length int, alphabet string) (string, error)
- func FormatFloat(num float64, decimal int) string
- func FormatStringToFloat(str string) float64
- func GenerateCipher(serverKey string, length int) string
- func GenerateETag(data []byte) string
- func GenerateInviteCode(userID int64) string
- func GenerateJWT(secret string, expireSeconds int64, claims map[string]interface{}) (string, error)
- func GenerateRandomString(length int) string
- func GenerateReferCode(userID int64) string
- func GenerateShortID(privateKey string) string
- func GenerateSubscribeToken(orderNo string) string
- func GenerateTradeNo() string
- func GenerateTurnstileIdempotencyKey() string
- func GenerateUUID() string
- func GetLastDayOfMonth(t time.Time) int64
- func GetYearDays(t time.Time, month int, day int) int64
- func HourDiff(startTime, endTime time.Time) int64
- func Int64SliceToString(intSlice []int64) string
- func Int64SliceToStringSlice(slice []int64) []string
- func Int64ToStringSlice(intSlice []int64) []string
- func IsValidImageSize(base64Str string, maxSizeKB int64) bool
- func JSONToStruct(jsonStr string, v interface{}) error
- func KeyNew(length int, keyType int) string
- func MaskEmail(email string) string
- func Md5Encode(str string, isUpper bool) string
- func MicrosecondsStr(elapsed time.Duration) string
- func MonthDiff(startTime, endTime time.Time) int
- func MultiPasswordVerify(algo, salt, passwordText, hash string) bool
- func ParseJWT(tokenString string, secret string) (map[string]interface{}, error)
- func ParseRedisURI(uri string) (addr, password string, database int, err error)
- func RedisPing(addr, password string, database int) error
- func RemoveDuplicateElements[T comparable](input ...T) []T
- func RemoveElementBySlice[T comparable](slice []T, element T) []T
- func RemoveStringElement(arr []string, element ...string) []string
- func RenderTemplateToString(tmpl string, data interface{}) (string, error)
- func ShallowCopy[T, K interface{}](destStruct T, srcStruct K, opts ...CopyOption) T
- func SliceDifferenceInt64(slice1, slice2 []int64) []int64
- func SliceIntersectInt64(slice1, slice2 []int64) []int64
- func SliceIsExistInt64(slice []int64, value int64) bool
- func StrToDashedString(strNum string) string
- func StringMergeAndRemoveDuplicates(strs ...string) []string
- func StringSliceContains(slice []string, str string) bool
- func StringSliceToInt64Slice(slice []string) []int64
- func StringSliceToString(stringSlice []string) string
- func StringToInt64Slice(s string) []int64
- func StringToStringSlice(str string) []string
- func StructToJSON(v interface{}) (string, error)
- func SystemConfigSliceReflectToStruct(slice []*SystemConfig, structType any)
- func Tern[T any](cond bool, a, b T) T
- func VerifyPassWord(passwd, EncodePasswd string) bool
- func VerifyTurnstile(ctx context.Context, secret, token, ip string) (bool, error)
- func VerifyTurnstileWithKey(ctx context.Context, secret, token, ip, idempotencyKey string) (bool, error)
- func YearDiff(startTime, endTime time.Time) int
- type CopyOption
- type SystemConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateNextResetTime ¶
CalculateNextResetTime 计算下次重置时间 与原项目 logic 完全一致
func CloneMapToStruct ¶
func Contains ¶
func Contains[T comparable](slice []T, target T) bool
func ConvertValueToString ¶
ConvertValueToString converts the value to string
func Curve25519Genkey ¶
func DaysToNextMonth ¶
func DeepCopy ¶
func DeepCopy[T, K any](destStruct T, srcStruct K, opts ...CopyOption) T
func EncodeBase36 ¶
EncodeBase36 encodes an int64 to base36 string
func EncodePassWord ¶
func ExtractVersionNumber ¶
func FixedUniqueString ¶
FixedUniqueString deterministically derives a short unique string from the input.
func FormatFloat ¶
func FormatStringToFloat ¶
func GenerateCipher ¶
GenerateCipher 根据公钥生成固定长度密文
func GenerateETag ¶
func GenerateInviteCode ¶
GenerateInviteCode generates an invite code from user ID
func GenerateJWT ¶
GenerateJWT generates a JWT token
func GenerateRandomString ¶
GenerateRandomString generates a random string with given length
func GenerateReferCode ¶
GenerateReferCode generates a refer code from user ID (alias for GenerateInviteCode)
func GenerateShortID ¶
func GenerateSubscribeToken ¶
GenerateSubscribeToken generates a subscription token from order number
func GenerateTradeNo ¶
func GenerateTradeNo() string
func GenerateTurnstileIdempotencyKey ¶
func GenerateTurnstileIdempotencyKey() string
func GetLastDayOfMonth ¶
GetLastDayOfMonth 获取指定时间所在月份的最后一天
func Int64SliceToString ¶
func Int64SliceToStringSlice ¶
func Int64ToStringSlice ¶
func IsValidImageSize ¶
IsValidImageSize 检查base64图片是否有效且未超出大小限制 base64Str: base64编码的图片字符串 maxSizeKB: 最大允许大小(KB),int64类型 返回: bool - true表示图片有效且未超限,false表示无效或超限
func JSONToStruct ¶
JSONToStruct converts JSON string to struct
func MicrosecondsStr ¶
func MultiPasswordVerify ¶
func ParseRedisURI ¶
func RemoveDuplicateElements ¶
func RemoveDuplicateElements[T comparable](input ...T) []T
func RemoveElementBySlice ¶
func RemoveElementBySlice[T comparable](slice []T, element T) []T
func RemoveStringElement ¶
RemoveStringElement 移除指定元素
func RenderTemplateToString ¶
func ShallowCopy ¶
func ShallowCopy[T, K interface{}](destStruct T, srcStruct K, opts ...CopyOption) T
func SliceDifferenceInt64 ¶
SliceDifferenceInt64 returns the difference of two slices
func SliceIntersectInt64 ¶
func SliceIsExistInt64 ¶
SliceIsExistInt64 checks if a value exists in a slice
func StrToDashedString ¶
StrToDashedString converts a string number to dashed format
func StringMergeAndRemoveDuplicates ¶
StringMergeAndRemoveDuplicates Tool function to convert multiple comma separated strings into [] strings and deduplicate them
func StringSliceContains ¶
func StringSliceToInt64Slice ¶
func StringSliceToString ¶
string slice to string
func StringToInt64Slice ¶
func StringToStringSlice ¶
StringToStringSlice splits a comma-separated string to slice
func StructToJSON ¶
StructToJSON converts a struct to JSON string
func SystemConfigSliceReflectToStruct ¶
func SystemConfigSliceReflectToStruct(slice []*SystemConfig, structType any)
func VerifyPassWord ¶
func VerifyTurnstile ¶
func VerifyTurnstileWithKey ¶
Types ¶
type CopyOption ¶
CopyOption 定义复制选项的函数类型
func CopyWithIgnoreEmpty ¶
func CopyWithIgnoreEmpty(ignoreEmpty bool) CopyOption
CopyWithIgnoreEmpty 设置是否忽略空值
type SystemConfig ¶
type SystemConfig struct {
ID int64 `json:"id"`
Category string `json:"category"`
Key string `json:"key"`
Value string `json:"value"`
Type string `json:"type"`
Desc string `json:"desc"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SystemConfig represents a system configuration entry This type is used for system configuration management