bvutils

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ServerAddr  string
	ServerIsTLS bool
)

Functions

func AssembleServerPath

func AssembleServerPath(filepath string) string

func ConvertRestfulURLToUri

func ConvertRestfulURLToUri(url string) (string, string)

ConvertRestfulURLToUri 将REST ful URL转换为URI

func ConvertToRestfulURL

func ConvertToRestfulURL(url string) string

ConvertToRestfulURL 将URI转换为REST ful URL

func DirIsEmpty

func DirIsEmpty(dirPath string) (bool, error)

目录是否为空

func DownloadFileAutoExt

func DownloadFileAutoExt(url string, filepath string) (string, error)

DownloadFileAutoExt 下载 URL 并保存到指定路径,第二个参数不要包含文件名 filepath: 文件保存路径, 会自动 md5 原URL 作为新文件的文件名

func FileIsExist

func FileIsExist(path string) (bool, error)

文件是否存在

func FunctionExists

func FunctionExists(dirPath, funcName string) (bool, error)

func GenerateNoWhippletreeUuid

func GenerateNoWhippletreeUuid() string

生成不带横杠的32位uuid

func GenerateUuid

func GenerateUuid() string

生成uuid

func GetBrowser

func GetBrowser(userAgent string) string

获取浏览器类型

func GetCallerName

func GetCallerName(caller interface{}) string

GetCallerName 获取调用者的名称

func GetClientRealIP

func GetClientRealIP(c *gin.Context) string

GetClientRealIP 获取客户端真实 IP(适用于 Gin 框架)

func GetLocalIP

func GetLocalIP() string

GetLocalIP 获取本机 IP

func GetMapSpecificValue

func GetMapSpecificValue[T MapSupportedTypes](m map[string]interface{}, key string) T

GetMapSpecificValue 获取map的特定类型的值, 相较于GetMapValue, 不用每次反射获取值

func GetMapValue

func GetMapValue[T any](m map[string]interface{}, key string) T

GetMapValue 获取map的值

func GetModuleName

func GetModuleName() (string, error)

GetModuleName 获取当前模块名称

func GetPlatform

func GetPlatform(userAgent string) string

获取操作系统

func GetRequestPath

func GetRequestPath(path, prefix string) (uri string, id int64)

GetRequestPath 获取请求路径

func GetServerAddr

func GetServerAddr() string

GetServerAddr 获取服务地址

func InArray

func InArray[T comparable](val T, slice []T) bool

InArray 判断某个值是否在数组中

func Interval64

func Interval64(min, max int64) int64

func IsValidNumber

func IsValidNumber[T Number](value T) bool

IsValidNumber 判断是否是有效数字

func JoinDomain

func JoinDomain(domain string, path string) string

JoinDomain 将域名和 URL 路径拼接为完整 URL

func LcFirst

func LcFirst(s string) string

LcFirst 字符串首字母小写

func MakePasswd

func MakePasswd(pwd, salt string) string

MakePasswd 生成密码

func Md5Encode

func Md5Encode(data string) string

Md5Encode md5处理

func RandString

func RandString(n int) string

func RemoveDomain

func RemoveDomain(rawURL string) string

RemoveDomain 移除URL中的域名

func RunSafe

func RunSafe(fn func())

func SafeGo

func SafeGo(fn func())

SafeGo 运行一个函数,并捕获panic

func SaveFile

func SaveFile(file *multipart.FileHeader, dst string) error

保存文件

func SeparateCamel

func SeparateCamel(name, separator string) string

SeparateCamel 按照自定符号分隔驼峰

func Ternary

func Ternary[T any](condition bool, trueVal, falseVal T) T

三元运算符

func UcFirst

func UcFirst(s string) string

UcFirst 字符串首字母大写

func ValidatePasswd

func ValidatePasswd(pwd, salt, passwd string) bool

ValidatePasswd 校验密码是否一致

Types

type MapSupportedTypes

type MapSupportedTypes interface {
	string | int64 | float64 | bool
}

type Number

type Number interface {
	~int | ~int32 | ~int64 | ~float64 | ~float32 | ~string
}

type OrderlyMap

type OrderlyMap struct {
	// contains filtered or unexported fields
}

有序 Map 严格按照Append的顺序执行, 先进先出, 同名会被覆盖

func NewOrderlyMap

func NewOrderlyMap() *OrderlyMap

func (*OrderlyMap) Append

func (self *OrderlyMap) Append(funcName string, value func())

func (*OrderlyMap) Foreach

func (self *OrderlyMap) Foreach()

Jump to

Keyboard shortcuts

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