Documentation
¶
Index ¶
- func BigNumberThousandFormat[...](num T) string
- func BytesToString[T ~[]byte](b T) string
- func CalculateAge(birthday string) string
- func Cartesian(data [][]uint64, delimiter string) []string
- func Contain[T comparable](itemList []T, item T) bool
- func CreateOrderNo() string
- func DiffSlice[T comparable](firstSlice []T, lastSlice []T) []T
- func DurationTime(pre time.Time) time.Duration
- func FileSizeFormat(fileSize uint64) string
- func GbkToUtf8(s []byte) ([]byte, error)
- func GeneratePassword(password string) (string, error)
- func GetLocalIp() string
- func HideCellphone(cellphone string) string
- func HideEmail(email string) string
- func HideRealName(name string) string
- func IfaceConvertInt64(data interface{}) int64
- func IfaceConvertString(data interface{}) string
- func IfaceConvertUint64(data interface{}) uint64
- func IndexOf[T comparable](itemList []T, item T) int
- func IsContainSlice[T comparable](maxSlice []T, minSlice []T) bool
- func IsSameYear(t time.Time) bool
- func IsToday(t time.Time) bool
- func LastDayOfMonth(t time.Time) time.Time
- func MaskCredNo(credNo string) string
- func MonthDays(t time.Time) int
- func RandAreaNum(min, max int) int
- func RandomNumberString(length int) string
- func RandomSliceUnique[T any](src []T, n int) []T
- func RandomString(length int, mode RandomStringMode) string
- func RemoveMarkdownLink(markdown string) string
- func ReplaceString(str string, findSlice, replaceSlice []string) string
- func ResolveTime(seconds int) (hour, minute, second int)
- func StringToBytes[T ~string](s T) []byte
- func Ternary[T any](condition bool, trueValue, falseValue T) T
- func TernaryFunc[T any](condition bool, trueFunc, falseFunc func() T) T
- func TernaryPtr[T any](condition bool, trueValue, falseValue *T) *T
- func Utf8ToGbk(s []byte) ([]byte, error)
- func VerifyPassword(hashedPassword string, plainPassword string) bool
- func WeekChinese(t time.Time) string
- func WeekChineseDay(t time.Time) string
- func WeekDay(t time.Time) uint8
- type RandomStringMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BigNumberThousandFormat ¶
func BigNumberThousandFormat[T ~uint | ~uint16 | ~uint32 | ~uint64 | int | int16 | int32 | int64 | float32 | float64](num T) string
BigNumberThousandFormat 大数千分位分割格式化
func DurationTime ¶
DurationTime 消耗时间计算 用法 defer DurationTime(time.Now()) 可计算函数执行时间
func FileSizeFormat ¶
FileSizeFormat 格式化文件大小 @param uint64 fileSize 文件大小(字节) @return string
func GeneratePassword ¶
GeneratePassword 生成密码 @param string password 明文密码 @return string
func IfaceConvertInt64 ¶
func IfaceConvertInt64(data interface{}) int64
IfaceConvertInt64 接口类型转换为int64
func IfaceConvertString ¶
func IfaceConvertString(data interface{}) string
IfaceConvertString 接口转换为字符串
func IfaceConvertUint64 ¶
func IfaceConvertUint64(data interface{}) uint64
IfaceConvertUint64 接口类型转换为uint64
func IsContainSlice ¶
func IsContainSlice[T comparable](maxSlice []T, minSlice []T) bool
IsContainSlice 判断2个切片是否有包含关系
func RandomNumberString ¶
RandomNumberString 生成随机数字字符串 @param int length 生成字符串长度
func RandomSliceUnique ¶
RandomSliceUnique 从切片中随机抽取 n 条不重复元素
func RandomString ¶
func RandomString(length int, mode RandomStringMode) string
RandomString 生成随机字符串 @param int length 生成字符串长度 @return string
func RemoveMarkdownLink ¶
RemoveMarkdownLink 去除markdown文档中的超链接
func ReplaceString ¶
ReplaceString 批量替换字符串
func ResolveTime ¶
ResolveTime 将整数转换为时分秒 @param int seconds 秒数 @return int hour 小时数 @return int minute 分钟数 @return int second 秒数
func TernaryFunc ¶
TernaryFunc 支持延迟计算的三元运算符 用法: result := TernaryFunc(condition, func() T { return trueValue }, func() T { return falseValue })
func TernaryPtr ¶
TernaryPtr 针对指针类型的三元运算符,避免nil指针问题
func VerifyPassword ¶
VerifyPassword 验证密码 @param string hashedPassword hash密码 @param string plainPassword 明文密码
func WeekChinese ¶
Types ¶
type RandomStringMode ¶
type RandomStringMode int
RandomStringMode 随机字符串模式
const ( ModeNumber RandomStringMode = iota // 纯数字 ModeLetter // 纯字母 ModeAlphanumeric // 字母和数字 ModeComplex // 复杂 )