Documentation
¶
Index ¶
- func BuildFTSQuery(input string) string
- func ByteCountSI(b int64) string
- func ComposeLANURL(addr string) string
- func DefaultWorkDir(account string) string
- func FindFilesWithPatterns(directory string, pattern string, recursive bool) ([]string, error)
- func GetDirSize(dir string) string
- func HideConsoleWindow()
- func IsNormalString(b []byte) bool
- func IsNumeric(s string) bool
- func LocalIPv4s(privateOnly bool) []string
- func MustAnyToInt(v interface{}) int
- func OpenBrowser(url string) error
- func PerfectTimeFormat(start time.Time, end time.Time) string
- func PrepareDir(path string) error
- func PrimaryLANIPv4() string
- func SplitInt64ToTwoInt32(input int64) (int64, int64)
- func Str2List(str string, sep string) []string
- func TimeOf(str string) (t time.Time, ok bool)
- func TimeRangeOf(str string) (start, end time.Time, ok bool)
- type TimeGranularity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildFTSQuery ¶
BuildFTSQuery 将用户输入转换为 SQLite FTS5 可以安全解析的查询表达式。 - 如果输入包含 AND/OR/NEAR/()/"/* 等高级语法,则直接返回原样,允许高级用户自行控制; - 否则将空白分隔的关键词转换为 "term" AND "term2" 的形式,避免意外的模糊匹配; - 同时会对双引号做转义处理,避免 MATCH 解析失败。
func ByteCountSI ¶
func ComposeLANURL ¶
ComposeLANURL constructs an http URL using the primary LAN IPv4 and the port from addr when addr binds all interfaces (0.0.0.0 or ::) or empty host. Otherwise returns http://addr as-is.
func DefaultWorkDir ¶
func FindFilesWithPatterns ¶
FindFilesWithPatterns 在指定目录下查找匹配多个正则表达式的文件 directory: 要搜索的目录路径 patterns: 正则表达式模式列表 recursive: 是否递归搜索子目录 返回匹配的文件路径列表和可能的错误
func GetDirSize ¶
func HideConsoleWindow ¶
func HideConsoleWindow()
HideConsoleWindow is a no-op on non-Windows platforms.
func IsNormalString ¶
func LocalIPv4s ¶
LocalIPv4s returns all local IPv4 addresses. If privateOnly is true, only returns RFC1918 addresses.
func MustAnyToInt ¶
func MustAnyToInt(v interface{}) int
func OpenBrowser ¶
OpenBrowser launches the user's default browser with the provided URL.
func PrepareDir ¶
PrepareDir ensures that the specified directory path exists. If the directory does not exist, it attempts to create it.
func PrimaryLANIPv4 ¶
func PrimaryLANIPv4() string
PrimaryLANIPv4 returns the first private IPv4 address, or empty string if none.
func SplitInt64ToTwoInt32 ¶
func TimeOf ¶
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 ¶
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 TimeGranularity ¶
type TimeGranularity int
时间粒度常量
const ( GranularityUnknown TimeGranularity = iota // 未知粒度 GranularitySecond // 精确到秒 GranularityMinute // 精确到分钟 GranularityHour // 精确到小时 GranularityDay // 精确到天 GranularityMonth // 精确到月 GranularityQuarter // 精确到季度 GranularityYear // 精确到年 )