tools

package
v0.0.0-...-b34c890 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsString

func AsString(src interface{}) string

AsString 转成string

func BuildDir

func BuildDir(absDir string) error

BuildDir 创建目录

func CheckFileIsExist

func CheckFileIsExist(filename string) bool

CheckFileIsExist 检查目录是否存在

func CheckParam

func CheckParam(params ...string) bool

CheckParam 检测参数

func DeleteFile

func DeleteFile(absDir string) error

DeleteFile 删除文件或文件夹

func FormatTime

func FormatTime(tm time.Time, forStr string) string

FormatTime 格式化时间

func GetCurrentDirectory

func GetCurrentDirectory() string

GetCurrentDirectory 获取exe所在目录

func GetDay0

func GetDay0(timestamp int64) time.Time

GetDay0 获取给定日期的零点时间

func GetDayStr

func GetDayStr(tm time.Time) string

GetDayStr 获取日期字符串

func GetHour

func GetHour(timestamp int64) int

GetHour 当前时间向上取整点

func GetHour0

func GetHour0(timestamp int64) time.Time

GetHour0 获取向上整时时间

func GetLastDayCurrentTime

func GetLastDayCurrentTime(timestamp int64, offset int) time.Time

GetLastDayCurrentTime 获取offset天的现在时间:注意时区

func GetLocalSystemLang

func GetLocalSystemLang(isSimple bool) (locale string)

GetLocalSystemLang 获取本地语言 (like:zh_CN.UTF-8)(simple:zh)

func GetLocalTime

func GetLocalTime(tm time.Time) time.Time

GetLocalTime 获取本地时间

func GetModelPath

func GetModelPath() string

GetModelPath 获取程序运行目录

func GetMonth0

func GetMonth0(timestamp int64) time.Time

GetMonth0 获取给定时间的当月1号零点时间

func GetPathDirs

func GetPathDirs(absDir string) (re []string)

GetPathDirs 获取目录所有文件夹

func GetPathFiles

func GetPathFiles(absDir string) (re []string)

GetPathFiles 获取目录所有文件

func GetSysTimeLayout

func GetSysTimeLayout() string

GetSysTimeLayout 获取系统时间的格式

func GetTimeStr

func GetTimeStr(tm time.Time) string

GetTimeStr 获取时间字符串

func GetTimeWeek

func GetTimeWeek(timestamp int64) int

GetTimeWeek 获取给定时间的星期

func GetUtcDay0

func GetUtcDay0(now time.Time, timeZone *time.Location) int64

GetUtcDay0 获取offset 0点时间

func GetUtcTime

func GetUtcTime(tm time.Time) int64

GetUtcTime 获取本地时间戳

func GetUtcWeek0

func GetUtcWeek0(timestamp int64) int64

GetUtcWeek0 获取最近上个星期天的零点日期

func GetWeek0

func GetWeek0(timestamp int64) time.Time

GetWeek0 获取最近上个星期天的零点日期

func Getenv

func Getenv(key string) string

Getenv 获取本地系统变量

func IsIDCard

func IsIDCard(cardNo string) bool

IsIDCard 判断是否是18或15位身份证

func IsInternalType

func IsInternalType(t string) bool

IsInternalType 是否是内部类型

func IsKeywords

func IsKeywords(t string) bool

IsKeywords 是否是关键字

func IsMail

func IsMail(username string) (isMail bool)

IsMail 判断用户是否是邮件用户

func IsPhone

func IsPhone(mobileNum string) bool

IsPhone 判断是否是手机号

func IsRunTesting

func IsRunTesting() bool

IsRunTesting 判断是否在测试环境下使用

func ReadFile

func ReadFile(fname string) (src []string)

ReadFile 读取文件

func SaveToFile

func SaveToFile(fname string, src []string, isClear bool) bool

SaveToFile 写入文件

func StrToTime

func StrToTime(tStr, format string, timeZone *time.Location) time.Time

StrToTime 字符串转时间

func StringTimetoUnix

func StringTimetoUnix(timestr string) int64

StringTimetoUnix 给定字符串时间转换成本地时间戳

func TimerByHour

func TimerByHour(f func())

TimerByHour 整点执行操作

func UnixToTime

func UnixToTime(timestamp int64) time.Time

UnixToTime 时间戳转换为time

func WriteFile

func WriteFile(fname string, src []string, isClear bool) bool

WriteFile 写入文件

Types

type Time

type Time struct {
	time.Time
}

Time json marsh 重写

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (Time) String

func (t Time) String() string

String ...

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON ...

Jump to

Keyboard shortcuts

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