util

package
v0.0.0-...-82cbb0b Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteCountSI

func ByteCountSI(b int64) string

func DefaultWorkDir

func DefaultWorkDir(account string) string

func FindFilesWithPatterns

func FindFilesWithPatterns(directory string, pattern string, recursive bool) ([]string, error)

FindFilesWithPatterns 在指定目录下查找匹配多个正则表达式的文件 directory: 要搜索的目录路径 patterns: 正则表达式模式列表 recursive: 是否递归搜索子目录 返回匹配的文件路径列表和可能的错误

func GetDirSize

func GetDirSize(dir string) string

func IsNormalString

func IsNormalString(b []byte) bool

func IsNumeric

func IsNumeric(s string) bool

func MustAnyToInt

func MustAnyToInt(v interface{}) int

func PerfectTimeFormat

func PerfectTimeFormat(start time.Time, end time.Time) string

func PrepareDir

func PrepareDir(path string) error

PrepareDir ensures that the specified directory path exists. If the directory does not exist, it attempts to create it.

func SplitInt64ToTwoInt32

func SplitInt64ToTwoInt32(input int64) (int64, int64)

func Str2List

func Str2List(str string, sep string) []string

func TimeOf

func TimeOf(str string) (t time.Time, ok bool)

TimeOf 解析各种格式的时间点 支持以下格式: 1. 时间戳(秒): 1609459200 2. 标准日期: 20060102, 2006-01-02 3. 带时间的日期: 20060102/15:04, 2006-01-02/15:04 4. 完整时间: 20060102150405 5. RFC3339: 2006-01-02T15:04:05Z07:00 6. 相对时间: 5h-ago, 3d-ago, 1w-ago, 1m-ago, 1y-ago (小时、天、周、月、年) 7. 自然语言: now, today, yesterday 8. 年份: 2006 9. 月份: 200601, 2006-01 10. 季度: 2006Q1, 2006Q2, 2006Q3, 2006Q4 11. 年月日时分: 200601021504

func TimeRangeOf

func TimeRangeOf(str string) (start, end time.Time, ok bool)

TimeRangeOf 解析各种格式的时间范围 支持以下格式: 1. 单个时间点: 根据时间粒度确定合适的时间范围

  • 精确到秒/分钟/小时: 扩展为当天范围
  • 精确到天: 当天 00:00:00 ~ 23:59:59
  • 精确到月: 当月第一天 ~ 最后一天
  • 精确到季度: 季度第一天 ~ 最后一天
  • 精确到年: 当年第一天 ~ 最后一天

2. 时间区间: 2006-01-01~2006-01-31, 2006-01-01,2006-01-31, 2006-01-01 to 2006-01-31 3. 相对时间: last-7d, last-30d, last-3m, last-1y (最近7天、30天、3个月、1年) 4. 特定时间段: today, yesterday, this-week, last-week, this-month, last-month, this-year, last-year 5. all: 表示所有时间

Types

type DLLLogger

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

DLLLogger DLL日志记录器

func GetDLLLogger

func GetDLLLogger() *DLLLogger

GetDLLLogger 获取DLL日志记录器单例

func (*DLLLogger) Close

func (l *DLLLogger) Close()

Close 关闭日志文件

func (*DLLLogger) GetLogPath

func (l *DLLLogger) GetLogPath() string

GetLogPath 获取日志文件路径

func (*DLLLogger) IsEnabled

func (l *DLLLogger) IsEnabled() bool

IsEnabled 检查日志是否启用

func (*DLLLogger) LogCleanup

func (l *DLLLogger) LogCleanup()

LogCleanup 记录清理信息

func (*DLLLogger) LogDebug

func (l *DLLLogger) LogDebug(message string)

LogDebug 记录调试信息

func (*DLLLogger) LogError

func (l *DLLLogger) LogError(message string)

LogError 记录错误信息

func (*DLLLogger) LogInfo

func (l *DLLLogger) LogInfo(message string)

LogInfo 记录普通信息

func (*DLLLogger) LogInitialization

func (l *DLLLogger) LogInitialization(pid uint32, success bool, errorMsg string)

LogInitialization 记录DLL初始化信息

func (*DLLLogger) LogPolling

func (l *DLLLogger) LogPolling(keyFound bool, key string, keyType string)

LogPolling 记录轮询信息

func (*DLLLogger) LogStatus

func (l *DLLLogger) LogStatus(level int, message string)

LogStatus 记录状态信息

func (*DLLLogger) LogWarning

func (l *DLLLogger) LogWarning(message string)

LogWarning 记录警告信息

type TimeGranularity

type TimeGranularity int

时间粒度常量

const (
	GranularityUnknown TimeGranularity = iota // 未知粒度
	GranularitySecond                         // 精确到秒
	GranularityMinute                         // 精确到分钟
	GranularityHour                           // 精确到小时
	GranularityDay                            // 精确到天
	GranularityMonth                          // 精确到月
	GranularityQuarter                        // 精确到季度
	GranularityYear                           // 精确到年
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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