common

package
v0.92.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   string = "dev"
	BuildTime string = "Unknown"
	Commit    string = "Unknown"
)
View Source
var Client *req.Client
View Source
var Logger *slog.Logger
View Source
var MeilisearchClient meilisearch.ServiceManager
View Source
var ResendClient *resend.Client
View Source
var TagRe = regexp.MustCompile(`(?:^|[\p{Zs}\s.,!?(){}[\]<>\"\',。!?():;、])#([\p{L}\d_]+)`)
View Source
var TaggerClient *taggerClient

Functions

func DownloadWithCache

func DownloadWithCache(ctx context.Context, url string, client *req.Client) ([]byte, error)

func EscapeHTML

func EscapeHTML(text string) string

func EscapeMarkdown

func EscapeMarkdown(text string) string

func ExtractTagsFromText

func ExtractTagsFromText(text string) []string

func FileExists

func FileExists(path string) bool

func GenerateRandomString

func GenerateRandomString(length int, charset ...string) string

func GetBodyReader added in v0.60.0

func GetBodyReader(ctx context.Context, url string, client *req.Client) (io.ReadCloser, error)

func GetReqCachedFile

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

func Init

func Init()

func MD5Hash added in v0.61.0

func MD5Hash(data string) string

func MkCache

func MkCache(path string, data []byte, td time.Duration)

func MkFile

func MkFile(path string, data []byte) error

创建文件, 自动创建目录

func ParseStringTo2DArray

func ParseStringTo2DArray(str, sep, sep2 string) [][]string

解析字符串为二维数组, 如果以字符串以引号包裹, 则无视分隔符

ParseStringTo2DArray("1,2,3;4,5,6", ",", ";") => [][]string{{"1", "2", "3"}, {"4", "5", "6"}}

ParseStringTo2DArray("1,2,3;\"4,5,6\"", ",", ";") => [][]string{{"1", "2", "3"}, {"4,5,6"}}

func PurgeFile

func PurgeFile(path string) error

删除文件, 并清理空目录. 如果文件不存在则返回 nil

func PurgeFileAfter

func PurgeFileAfter(path string, td time.Duration)

在指定时间后删除和清理文件 (定时器)

func RemoveEmptyDirectories

func RemoveEmptyDirectories(dirPath string) error

递归删除空目录

func RmFileAfter added in v0.60.0

func RmFileAfter(path string, td time.Duration)

func SanitizeFileName added in v0.86.0

func SanitizeFileName(fileName string) string

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