utils

package
v1.0.0-rc.10 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CSTLocation = time.FixedZone("CST", 8*3600)

CSTLocation is the China Standard Time timezone (UTC+8). All PT sites (M-Team, HDSky, SpringSunday, HDDolby, etc.) return times in CST.

Functions

func CheckDirectory

func CheckDirectory(path string) (exists, empty bool, err error)

CheckDirectory 检查目录是否存在且为空 返回值: - exists: 目录是否存在 - empty: 目录是否为空(如果存在) - err: 错误信息(如果存在)

func DirectoryExists

func DirectoryExists(path string) (bool, error)

func FormatBytes

func FormatBytes(n int64) string

FormatBytes 把字节数格式化成 IEC 单位(B、KiB、MiB、GiB、TiB、PiB),1 KiB 以上保留两位小数。

func IsDirectoryEmpty

func IsDirectoryEmpty(path string) (bool, error)

func ParseTimeInCST added in v0.3.0

func ParseTimeInCST(layout, value string) (time.Time, error)

ParseTimeInCST parses a time string in CST timezone.

func RedactURLError

func RedactURLError(err error) error

RedactURLError 把错误链里 *url.Error 的地址换成脱敏后的地址,返回原错误。 net/http 的传输错误会把完整请求地址(RSS、种子下载地址常带 passkey)写进错误文本。 要在包装之前调用:fmt.Errorf 包装时就把错误文本定下了。

func ResolveDownloadBase added in v0.1.1

func ResolveDownloadBase(home, work, dir string) (string, error)

func SanitizeURL added in v0.6.0

func SanitizeURL(rawURL string) string

SanitizeURL 对 URL 中的敏感查询参数进行脱敏处理 返回脱敏后的 URL 字符串,敏感参数值会被替换为 "***" 如果解析失败,返回 "<invalid-url>"

func SubPathFromTag added in v0.1.1

func SubPathFromTag(tag string) string

Types

type Locker added in v0.0.14

type Locker interface {
	Lock() error
	Unlock() error
	File() *os.File
}

定义统一接口

func NewLocker added in v0.0.14

func NewLocker(lockPath string) (Locker, error)

Directories

Path Synopsis
Package httpclient 提供基于 github.com/sunerpy/requests 的 HTTP 客户端连接池管理
Package httpclient 提供基于 github.com/sunerpy/requests 的 HTTP 客户端连接池管理

Jump to

Keyboard shortcuts

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