Documentation
¶
Index ¶
- func ByteCountSI(b int64) string
- func DefaultWorkDir(account string) string
- func FindFilesWithPatterns(directory string, pattern string, recursive bool) ([]string, error)
- func GetDirSize(dir string) string
- func IsNormalString(b []byte) bool
- func IsNumeric(s string) bool
- func MustAnyToInt(v interface{}) int
- func PerfectTimeFormat(start time.Time, end time.Time) string
- func PrepareDir(path string) error
- 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 ByteCountSI ¶
func DefaultWorkDir ¶
func FindFilesWithPatterns ¶
FindFilesWithPatterns 在指定目录下查找匹配多个正则表达式的文件 directory: 要搜索的目录路径 patterns: 正则表达式模式列表 recursive: 是否递归搜索子目录 返回匹配的文件路径列表和可能的错误
func GetDirSize ¶
func IsNormalString ¶
func MustAnyToInt ¶
func MustAnyToInt(v interface{}) int
func PrepareDir ¶
PrepareDir ensures that the specified directory path exists. If the directory does not exist, it attempts to create it.
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 // 精确到年 )