utils

package
v0.0.0-...-fff2389 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GBTimeValFormatYMD    = "20060102"
	GBTimeValFormatYMDSep = "2006-01-02"
)

Variables

View Source
var (
	// 中国本地时区变量
	GBTimeValLocalChina *time.Location
)

Functions

func GBFileIsExist

func GBFileIsExist(filePath string) bool

文件是否存在

func GBFileReadAndSplitLineAsInt64Slice

func GBFileReadAndSplitLineAsInt64Slice(filePath string) ([]int64, error)

读取文件内容,按行拆分为 int64 数组

func GBFileReadAndSplitLineAsStringSlice

func GBFileReadAndSplitLineAsStringSlice(filePath string) ([]string, error)

读取文件内容,按行拆分为 string 数组

func GBFileReadAsInt64

func GBFileReadAsInt64(filePath string) (int64, error)

读取文件内容,并转换为 int64

func GBFileReadAsString

func GBFileReadAsString(filePath string) (string, error)

读取文件内容作为字符串

func GBFileReadAsTrimString

func GBFileReadAsTrimString(filePath string) (string, error)

读取文件内容作为字符串,并且修剪

func GBFileWriteInt64

func GBFileWriteInt64(filePath string, value int64) error

将 int64 值写入文件

func GBFileWriteString

func GBFileWriteString(filePath string, str string) error

将 string 值写入文件

func GBPathAbsExecutable

func GBPathAbsExecutable() string

获取当前执行程序的绝对路径

func GBPathAbsFolderOfExecutable

func GBPathAbsFolderOfExecutable() string

获取当前执行程序的所在目录,绝对路径

func GBPathAbsRelativeExecutable

func GBPathAbsRelativeExecutable(filepath string) string

获取基于当前执行程序所在目录的文件绝对路径

func GBStringJoinArgs

func GBStringJoinArgs(sep string, args ...interface{}) string

将数组拼接为字符串

func GBStringJoinAuto

func GBStringJoinAuto(sep string, sliceOrArray interface{}) string

将 数组/切片 拼接为字符串

func GBTimeForRangeEachDay

func GBTimeForRangeEachDay(timeBeg, timeEnd time.Time, fcb func(time.Time))

从"起始时间(包含)"到"结束时间(不含)"循环范围内的每一[天],本地时区

func GBTimeFormatReadable

func GBTimeFormatReadable(t time.Time) string

格式化时间,变成易读的,使用内置的默认格式,只具体到毫秒

func GBTimeGetStart0OfTimeDay

func GBTimeGetStart0OfTimeDay(t time.Time) time.Time

//////////////////////////////////////////////////////////////////////////////////////////////////////////// 传入一个时间,取得这个时间那天的起始时间,即零点的时间

func GBTimeGetTodayAndAfterDays

func GBTimeGetTodayAndAfterDays(dayCount int) []time.Time

取得当前天以及向后N天的时间

func GBTimeGetTodayAndAfterDaysFormat

func GBTimeGetTodayAndAfterDaysFormat(dayCount int, fmt string) []string

取得当前天以及向后N天的时间,并格式化

func GBTimeGetTodayAndBeforeDays

func GBTimeGetTodayAndBeforeDays(dayCount int) []time.Time

//////////////////////////////////////////////////////////////////////////////////////////////////////////// 取得当前天以及向前N天的时间

func GBTimeGetTodayAndBeforeDaysFormat

func GBTimeGetTodayAndBeforeDaysFormat(dayCount int, fmt string) []string

取得当前天以及向前N天的时间,并格式化

func GBTimeGetTodayFormat

func GBTimeGetTodayFormat(fmt string) string

取得当前天,并格式化

func GBTimeGetTodayFormatYMDAsInt64

func GBTimeGetTodayFormatYMDAsInt64() int64

取得当前天,格式化并转换为整数

func GBTimeLocalDate

func GBTimeLocalDate(year int, month time.Month, day, hour, min, sec, nsec int) time.Time

//////////////////////////////////////////////////////////////////////////////////////////////////////////// 根据日期取得时间实例,中国本地时区的

func GBTimeNowUnixMS

func GBTimeNowUnixMS() int64

取得当前系统 unix 毫秒

func GBTimeNowUnixNS

func GBTimeNowUnixNS() int64

//////////////////////////////////////////////////////////////////////////////////////////////////////////// 取得当前系统 unix 纳秒

func GBTimeNowUnixS

func GBTimeNowUnixS() int64

取得当前系统 unix 秒

func GBTimeNowUnixUS

func GBTimeNowUnixUS() int64

取得当前系统 unix 微秒

func GBTimeParseFromFormatString

func GBTimeParseFromFormatString(timestr string, fmt string) time.Time

通过格式化取得时间,本地时区

func GBTimeParseFromFormatStringLocation

func GBTimeParseFromFormatStringLocation(timestr string, fmt string, local *time.Location) time.Time

//////////////////////////////////////////////////////////////////////////////////////////////////////////// 通过格式化取得时间

Types

This section is empty.

Jump to

Keyboard shortcuts

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