pkg

package
v0.0.0-...-d6722f6 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// OnlyNumber 只包含数字的正则表达式
	OnlyNumber *regexp.Regexp

	// ContainChinese 包含中文字符的正则表达式
	ContainChinese *regexp.Regexp

	// Email 邮箱
	Email *regexp.Regexp

	// Phone 手机号(中国)
	Phone *regexp.Regexp
)

Functions

func BalancedWildcards

func BalancedWildcards(text string, dict map[string]string) bool

BalancedWildcards 判断文本中的通配符对是否配对

func CopyDir

func CopyDir(src, dst string, ignores []string) error

CopyDir 拷贝目录

func CopyFile

func CopyFile(src, dst string) error

CopyFile 拷贝文件

func CronTask

func CronTask(spec string, callback func())

CronTask Cron定时任务

func DelSliceElement

func DelSliceElement[T any](list []T, idx int) []T

DelSliceElement 删除切片中某个下标的元素

func ExtractTextBetweenWildcards

func ExtractTextBetweenWildcards(text, start, end string) []string

ExtractTextBetweenWildcards 提取被通配符包含的内容包含通配符本身

func FileMD5

func FileMD5(fp string) (string, error)

FileMD5 获取文件MD5

func GET

func GET(url string) ([]byte, error)

GET 发送HTTP GET请求

func HTTP

func HTTP(url, method string, body []byte, headers map[string]string) ([]byte, error)

HTTP 发送HTTP请求

func LogicalPaginate

func LogicalPaginate[T any](list []T, pageNo, pageSize int64) []T

LogicalPaginate 逻辑分页,返回分页后的数组

func MD5

func MD5(text string) string

MD5 md5

func POST

func POST(url string, body []byte) ([]byte, error)

POST 发送HTTP POST请求

func PathExists

func PathExists(src string) bool

PathExists 判断文件或目录是否存在

func RemoveSliceDuplicates

func RemoveSliceDuplicates[E comparable](slice []E) []E

RemoveSliceDuplicates slice去重

func Sign

func Sign(params map[string]string, secret string) string

Sign 接口签名

func SimpleTask

func SimpleTask(duration time.Duration, callback func())

SimpleTask 简单的定时任务,不建议在生产环境中使用

func TimeoutTask

func TimeoutTask(ctx context.Context, timeout time.Duration, fn func(timeoutCtx context.Context) error) error

TimeoutTask 带过期时间的任务

func ZipCompress

func ZipCompress(files []string, des string, abs bool) error

ZipCompress 压缩指定文件集

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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