helper

package
v0.0.0-...-5cf9733 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayChunk

func ArrayChunk[T any](arr []T, size int) [][]T

ArrayChunk 数组分组

func GenerateBaseSnowId

func GenerateBaseSnowId(num int, n *snowflake.Node) string

GenerateBaseSnowId 生成雪花算法ID

func GenerateHash

func GenerateHash(str string) string

GenerateHash 生成md5 hash值

func GeneratePasswordHash

func GeneratePasswordHash(password string, salt string) string

GeneratePasswordHash 生成密码hash值

func GenerateUuid

func GenerateUuid(size int) string

GenerateUuid 生成随机字符串

func GetAllDirs

func GetAllDirs(root string) ([]string, error)

GetAllDirs 获取指定文件夹中所有文件夹路径

func GetFileNamesByDirPath

func GetFileNamesByDirPath(root string) ([]map[string]interface{}, error)

GetFileNamesByDirPath 获取当前文件夹下的所有文件和文件夹名称(包括子文件夹和文件)

func GetKeyByMap

func GetKeyByMap[T comparable](m map[string]T, value T) string

GetKeyByMap 根据map中的值获取键

func GetLocalIp

func GetLocalIp() (string, error)

GetLocalIp 获取本机ip

func GetLocalIpToInt

func GetLocalIpToInt() (int, error)

GetLocalIpToInt 获取本机IP转成int

func GetProjectModuleName

func GetProjectModuleName() string

GetProjectModuleName 获取当前项目的module名称

func GetStructColumnName

func GetStructColumnName(s interface{}, _type int) ([]string, error)

GetStructColumnName 获取结构体中的字段名称 _type: 1: 获取tag字段值 2:获取结构体字段值

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 IsPathExist

func IsPathExist(path string) bool

IsPathExist 判断所给路径文件/文件夹是否存在

func MakeFileOrPath

func MakeFileOrPath(path string) (*os.File, error)

MakeFileOrPath 创建文件/文件夹

func MakeMultiDir

func MakeMultiDir(filePath string) error

MakeMultiDir 调用os.MkdirAll递归创建文件夹

func MakeTimeFormatDir

func MakeTimeFormatDir(rootPath, pathName, timeFormat string) (string, error)

MakeTimeFormatDir @Description: 创建时间格式的目录 如:upload/{path}/2023-01-07/ @param rootPath 根目录 @param pathName 子目录名称 @param timeFormat 时间格式 如:2006-01-02、20060102 @return string @return error

func RandString

func RandString(length int) string

RandString 随机字符串

func String2Int

func String2Int(strArr []string) []int

String2Int 将数组的string转int

func ToCamelCase

func ToCamelCase(s string) string

ToCamelCase 将字符串转换成驼峰写法

func WriteContentToFile

func WriteContentToFile(file *multipart.FileHeader, filePath string) error

WriteContentToFile @Description: 写文件 @param filePath @return error

Types

This section is empty.

Jump to

Keyboard shortcuts

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