Documentation
¶
Index ¶
- func AnyToInts[T comparable](numbers []T) []int
- func AnyToUint64[T comparable](numbers []T) []uint64
- func ArrayChunk[T any](arr []T, size int) [][]T
- func ConvertSlice2MapIdKey(slice interface{}, keyExtractor KeyExtractor) map[uint64]interface{}
- func GenerateAppCode(mchId uint64) string
- func GenerateAppKeyPair() (string, string)
- func GenerateBaseSnowId(num int, n *snowflake.Node) string
- func GenerateClientId() string
- func GenerateCode(length int) string
- func GenerateHash(str string) string
- func GenerateId() string
- func GeneratePasswordHash(password string, salt string) string
- func GenerateRandomString(length int) string
- func GenerateSeqNo(prefix string, mchId uint64) string
- func GenerateUUID() int64
- func GenerateUuid(size int) string
- func GetAllDirs(root string) ([]string, error)
- func GetDeliveryTime(distance int, startDistance int, startTime int, addDistance int, addTime int) int
- func GetFileNamesByDirPath(root string) ([]map[string]interface{}, error)
- func GetKeyByMap[T comparable](m map[string]T, value T) string
- func GetLocalIp() (string, error)
- func GetLocalIpToInt() (int, error)
- func GetProjectModuleName() string
- func GetStructColumnName(s interface{}, _type int) ([]string, error)
- func GetUploadFileBytes(file *multipart.FileHeader) ([]byte, error)
- func InAnyKeyMap[T comparable, V comparable](haystack map[T]V, needle T) bool
- func InAnyMap[T comparable](haystack map[string]T, needle T) bool
- func InAnySlice[T comparable](haystack []T, needle T) bool
- func IntsToString[T any](numbers []T, sep string) string
- func IsPathExist(path string) bool
- func IsValidEmail(email string) bool
- func IsValidPhone(phone string) bool
- func MakeFileOrPath(path string) (*os.File, error)
- func MakeMultiDir(filePath string) error
- func MakeTimeFormatDir(rootPath, pathName, timeFormat string) (string, error)
- func RandString(length int) string
- func ReadLocalFile(filePath string) ([]byte, error)
- func String2Int(strArr []string) []int
- func StructToMap(obj interface{}) map[string]interface{}
- func ToCamelCase(s string) string
- func ToPointer[T comparable](s T) *T
- func ValidateAppKeyPair(appKey string, appSecret string) bool
- func WriteBytesToFile(data []byte, filePath string) error
- func WriteContentToFile(file *multipart.FileHeader, filePath string) error
- type KeyExtractor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyToUint64 ¶
func AnyToUint64[T comparable](numbers []T) []uint64
AnyToUint64 将任何类型的切片转化成uin64t切片
func ConvertSlice2MapIdKey ¶
func ConvertSlice2MapIdKey(slice interface{}, keyExtractor KeyExtractor) map[uint64]interface{}
ConvertSlice2MapIdKey slice 转换为map ,key采用通用的id
func GenerateAppKeyPair ¶
GenerateAppKeyPair 生成应用的AK和SK密钥对 返回值: appKey string, appSecret string
func GenerateBaseSnowId ¶
GenerateBaseSnowId 生成雪花算法ID 废弃
func GenerateClientId ¶
func GenerateClientId() string
func GeneratePasswordHash ¶
GeneratePasswordHash 生成密码hash值
func GenerateRandomString ¶
GenerateRandomString 生成随机字符串
func GenerateSeqNo ¶
GenerateSeqNo 生成业务流水编号 前缀: 发票:FP 账单:ZD 交易:JY 提现:TX 充值:CZ 汇款:HK 开通:KT 格式:{前缀}{YYMMDDHHmmss}{商家ID(6-8位)}{随机数字(4-6位)}
func GetDeliveryTime ¶
func GetDeliveryTime(distance int, startDistance int, startTime int, addDistance int, addTime int) int
GetDeliveryTime 计算配送时间 配送时间默认3000m以内60分钟,超过1000m增加5分钟,返回秒
func GetFileNamesByDirPath ¶
GetFileNamesByDirPath 获取当前文件夹下的所有文件和文件夹名称(包括子文件夹和文件)
func GetKeyByMap ¶
func GetKeyByMap[T comparable](m map[string]T, value T) string
GetKeyByMap 根据map中的值获取键
func GetStructColumnName ¶
GetStructColumnName 获取结构体中的字段名称 _type: 1: 获取tag字段值 2:获取结构体字段值
func GetUploadFileBytes ¶
func GetUploadFileBytes(file *multipart.FileHeader) ([]byte, error)
GetUploadFileBytes 获取上传文件的数据流
func InAnyKeyMap ¶
func InAnyKeyMap[T comparable, V comparable](haystack map[T]V, needle T) bool
InAnyKeyMap 判断某个map的键是否存在
func InAnyMap ¶
func InAnyMap[T comparable](haystack map[string]T, needle T) bool
InAnyMap 判断某个map的值是否存在
func InAnySlice ¶
func InAnySlice[T comparable](haystack []T, needle T) bool
InAnySlice 判断某个字符串是否在字符串切片中
func IntsToString ¶
IntsToString 将int切片转换成字符串
func MakeTimeFormatDir ¶
MakeTimeFormatDir 创建时间格式的目录 如:upload/{path}/2023-01-07/
rootPath 根目录 pathName 子目录名称 timeFormat 时间格式 如:2006-01-02、20060102
func ReadLocalFile ¶
ReadLocalFile 读取本地文件并返回字节数组数据
func StructToMap ¶
func StructToMap(obj interface{}) map[string]interface{}
StructToMap 使用反射将结构体转换为 map
func ValidateAppKeyPair ¶
ValidateAppKeyPair 验证AK/SK密钥对格式是否合法
func WriteBytesToFile ¶
WriteBytesToFile 将字节数组数据写入本地文件
func WriteContentToFile ¶
func WriteContentToFile(file *multipart.FileHeader, filePath string) error
WriteContentToFile 将文件内容写入指定路径
Types ¶
type KeyExtractor ¶
type KeyExtractor func(interface{}) uint64