helper

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

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 BytesToString

func BytesToString[T ~[]byte](b T) string

BytesToString 字节数组转字符串

func Cartesian

func Cartesian(data [][]uint64, delimiter string) []string

Cartesian 计算矩阵笛卡尔积

func Contain

func Contain[T comparable](itemList []T, item T) bool

Contain 判断元素是否包含在列表中

func CreateOrderNo

func CreateOrderNo() string

CreateOrderNo 生成唯一订单号 @return string

func DiffSlice

func DiffSlice[T comparable](firstSlice []T, lastSlice []T) []T

DiffSlice 切片差集

func DurationTime

func DurationTime(pre time.Time) time.Duration

DurationTime 消耗时间计算 用法 defer DurationTime(time.Now()) 可计算函数执行时间

func FileSizeFormat

func FileSizeFormat(fileSize uint64) string

FileSizeFormat 格式化文件大小 @param uint64 fileSize 文件大小(字节) @return string

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

GbkToUtf8 GBK 转 UTF-8

func GeneratePassword

func GeneratePassword(password string) (string, error)

GeneratePassword 生成密码 @param string password 明文密码 @return string

func GetLocalIp

func GetLocalIp() string

GetLocalIp 获取本机IP地址 @return string

func HideCellphone

func HideCellphone(cellphone string) string

HideCellphone 隐藏手机号码中间四位

func HideEmail

func HideEmail(email string) string

func HideRealName

func HideRealName(name string) string

HideRealName 隐藏姓名中间文字

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 IndexOf

func IndexOf[T comparable](itemList []T, item T) int

IndexOf 获取元素在数组中的位置

func IsContainSlice

func IsContainSlice[T comparable](maxSlice []T, minSlice []T) bool

IsContainSlice 判断2个切片是否有包含关系

func IsSameYear

func IsSameYear(t time.Time) bool

IsSameYear 是否为同一年

func IsToday

func IsToday(t time.Time) bool

IsToday 是否为今天

func LastDayOfMonth

func LastDayOfMonth(t time.Time) time.Time

LastDayOfMonth 获取月份最后一天日期

func MonthDays

func MonthDays(t time.Time) int

MonthDays 获取月份天数

func RandAreaNum

func RandAreaNum(min, max int) int

RandAreaNum 区间随机数(2端闭合区间)

func RandomNumberString

func RandomNumberString(length int) string

RandomNumberString 生成随机数字字符串 @param int length 生成字符串长度

func RandomString

func RandomString(length int, mode RandomStringMode) string

RandomString 生成随机字符串 @param int length 生成字符串长度 @return string

func RemoveMarkdownLink(markdown string) string

RemoveMarkdownLink 去除markdown文档中的超链接

func ReplaceString

func ReplaceString(str string, findSlice, replaceSlice []string) string

ReplaceString 批量替换字符串

func ResolveTime

func ResolveTime(seconds int) (hour, minute, second int)

ResolveTime 将整数转换为时分秒 @param int seconds 秒数 @return int hour 小时数 @return int minute 分钟数 @return int second 秒数

func StringToBytes

func StringToBytes[T ~string](s T) []byte

StringToBytes 字符串转字节数组

func UUID

func UUID() string

UUID uuid

func UUIDv4

func UUIDv4() string

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

Utf8ToGbk Utf8 转 gbk

func VerifyPassword

func VerifyPassword(hashedPassword string, plainPassword string) error

VerifyPassword 验证密码 @param string hashedPassword hash密码 @param string plainPassword 明文密码

func WeekChinese

func WeekChinese(t time.Time) string

func WeekChineseDay

func WeekChineseDay(t time.Time) string

WeekChineseDay 获取星期几中文名称

func WeekDay

func WeekDay(t time.Time) uint8

WeekDay 获取星期几

Types

type RandomStringMode

type RandomStringMode int

RandomStringMode 随机字符串模式

const (
	ModeNumber       RandomStringMode = iota // 纯数字
	ModeLetter                               // 纯字母
	ModeAlphanumeric                         // 字母和数字
	ModeComplex                              // 复杂
)

Jump to

Keyboard shortcuts

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