Documentation
¶
Index ¶
- func Able(name string) string
- func Base64Decode(encodedText string) (string, error)
- func Base64Encode(text string) string
- func CamelCase(str string) string
- func CamelCaseWithSpecial(str string) string
- func CamelColon(str string) string
- func ComparePasswords(hashedPassword, password string) bool
- func DoubleHash(text string) string
- func GenerateSalt(length int) string
- func GenerateSignature(length int, prefix string) (string, error)
- func GetEnv(key string, defaultValue ...string) string
- func GetEnvArray(key string, sep string, defaultValue ...[]string) []string
- func GetEnvBool(key string, defaultValue ...bool) bool
- func GetEnvFloat64(key string, defaultValue ...float64) float64
- func GetEnvFloat64Array(key string, sep string, defaultValue ...[]float64) []float64
- func GetEnvInt(key string, defaultValue ...int) int
- func GetEnvInt64(key string, defaultValue ...int64) int64
- func GetEnvInt64Array(key string, sep string, defaultValue ...[]int64) []int64
- func GetEnvIntArray(key string, sep string, defaultValue ...[]int) []int
- func GetFileDir(path string) (string, error)
- func GetFilePath(path string) (string, error)
- func GetGoModPath() (string, error)
- func GetGoPath() string
- func GetModPath(projectPath *string) (string, error)
- func GetModuleRoot() (string, error)
- func GetPkgPath(projectPath, filePath string) (string, error)
- func GetProjectPath() (string, error)
- func HashAndSalt(value string) (string, error)
- func HashWithPepper(password string, pepper string) string
- func HashWithSalt(password string, salt string) string
- func IsHashAndSalt(value string, plainLength int) bool
- func IsInternalType(name string) bool
- func IsValidAmount(amount string) bool
- func IsValidBankCard(card string) bool
- func IsValidDate(date string) bool
- func IsValidDateTime(datetime string) bool
- func IsValidIDCard(id string) bool
- func IsValidIP(ip string) bool
- func IsValidIPv6(ip string) bool
- func IsValidPhoneNumber(phone string) bool
- func IsValidPostCode(code string) bool
- func IsValidTime(timeStr string) bool
- func Lc(str string) string
- func LcFirst(str string) string
- func MD5Hash(text string) string
- func MkdirAll(path string) error
- func ParseJSONNumberToI64(num json.Number) (int, error)
- func PascalCase(str string) string
- func Pluralize(word string) string
- func RandomBool() bool
- func RandomChoice[T any](slice []T) T
- func RandomCode(length int) string
- func RandomFloat(min, max float64) float64
- func RandomInt(min, max int) int
- func RandomLowerString(length int) string
- func RandomString(length int) string
- func RandomTime(start, end time.Time) time.Time
- func RandomUpperString(length int) string
- func SHA1Hash(text string) string
- func SHA256Hash(text string) string
- func SHA512Hash(text string) string
- func SmoothProgress(start, end int, status string, duration time.Duration, keepVisible bool)
- func SnakeCase(str string) string
- func StrPtr(str string) *string
- func UcFirst(str string) string
- func VerifyHash(text string, hash string, algorithm string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶ added in v1.2.0
Base64Decode 将Base64编码的字符串解码
func Base64Encode ¶ added in v1.2.0
Base64Encode 将字符串进行Base64编码
func CamelCaseWithSpecial ¶ added in v1.2.0
CamelCaseWithSpecial 驼峰命名(特殊单词会保持大写)
func CamelColon ¶ added in v1.2.0
CamelColon 将驼峰命名转换为路径格式 (例如: ProcessTask -> process::task)
func ComparePasswords ¶ added in v1.2.0
ComparePasswords 比较哈希密码和输入的密码
func GenerateSignature ¶ added in v1.2.0
func GetEnvArray ¶ added in v1.2.0
GetEnvArray Get the value of the environment variable as a string array
func GetEnvBool ¶ added in v1.2.0
GetEnvBool Get the value of the environment variable as a bool
func GetEnvFloat64 ¶ added in v1.2.0
GetEnvFloat64 Get the value of the environment variable as a float64
func GetEnvFloat64Array ¶ added in v1.2.0
GetEnvFloat64Array Get the value of the environment variable as a float64 array
func GetEnvInt64 ¶ added in v1.2.0
GetEnvInt64 Get the value of the environment variable as an int64
func GetEnvInt64Array ¶ added in v1.2.0
GetEnvInt64Array Get the value of the environment variable as an int64 array
func GetEnvIntArray ¶ added in v1.2.0
GetEnvIntArray Get the value of the environment variable as an int array
func GetFileDir ¶
GetFileDir returns the directory containing the file
func GetGoModPath ¶ added in v1.2.5
GetGoModPath returns the path to go.mod file using go env GOMOD
func GetModPath ¶
GetModPath returns the module path using go env GOMOD Note: projectPath parameter is deprecated and ignored; go env GOMOD is used instead
func GetModuleRoot ¶ added in v1.2.5
GetModuleRoot returns the module root directory (directory containing go.mod)
func GetPkgPath ¶
GetPkgPath returns the package path Note: projectPath parameter is deprecated and ignored; go env GOMOD is used instead
func GetProjectPath ¶
GetProjectPath returns the project root path
func HashAndSalt ¶ added in v1.2.0
HashAndSalt 对字符串加密
func HashWithPepper ¶ added in v1.2.0
HashWithPepper 将密码与pepper(固定盐值)组合后进行哈希
func HashWithSalt ¶ added in v1.2.0
HashWithSalt 将密码与盐值组合后进行哈希
func IsHashAndSalt ¶ added in v1.2.0
func IsInternalType ¶
func IsValidAmount ¶ added in v1.2.0
IsValidAmount 金额校验 格式: 123.45
func IsValidBankCard ¶ added in v1.2.0
IsValidBankCard checks if Chinese bank card number is valid (16-19 digits)
func IsValidDate ¶ added in v1.2.0
IsValidDate 日期校验 格式: YYYY-MM-DD
func IsValidDateTime ¶ added in v1.2.0
IsValidDateTime 日期时间校验 格式: YYYY-MM-DD HH:MM:SS
func IsValidIDCard ¶ added in v1.2.0
IsValidIDCard 验证身份证号码是否有效 支持15位老身份证、18位新身份证和外国人永久居留证 15位身份证格式: PPPPPPYYMMDDXXX 18位身份证格式: PPPPPPYYYYMMDDXXXC 外国人永久居留证格式: 前3位为字母,后13位为数字 P: 省份和城市代码, Y: 年份, M: 月份, D: 日期, X: 顺序码, C: 校验码
func IsValidPhoneNumber ¶ added in v1.2.0
IsValidPhoneNumber 校验中国手机号 中国手机号的正则表达式:以1开头,第二位是3-9,后面跟9个数字,总共11位
func IsValidPostCode ¶ added in v1.2.0
IsValidPostCode 邮编校验 仅针对中国大陆邮编
func IsValidTime ¶ added in v1.2.0
IsValidTime 时间校验 格式: HH:MM:SS
func SmoothProgress ¶ added in v1.2.0
Types ¶
This section is empty.