util

package
v0.0.0-...-d62e3dc Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeFormat = "2006-01-02 15:04:05"

Variables

This section is empty.

Functions

func Assert

func Assert(b bool, text string)

func Assertf

func Assertf(b bool, format string, args ...any)

func CopyBytes

func CopyBytes(src []byte) (dst []byte)

func DeserializeFromStringArray

func DeserializeFromStringArray(i any, stringArray []string) (err error)

func DeserializeStructFromExcelRow

func DeserializeStructFromExcelRow(e any, row *xlsx.Row) (err error)

func Format

func Format(format string, args ...any) string

func FormatFieldName

func FormatFieldName(rawName string) string

格式化字段名, 比如: xlsx表字段, mysql表字段

func GetBuffer

func GetBuffer() *bytes.Buffer

func GetDurationToNextHalfHour

func GetDurationToNextHalfHour() time.Duration

GetDurationToNextHalfHour 获取下个整点或半小时到当前的时差

func GetDurationToNextMinute

func GetDurationToNextMinute() time.Duration

GetDurationToNextMinute 获取当前和下一分钟的时差

func GetFileBaseName

func GetFileBaseName(file string) string

GetFileBaseName 获取路径中的文件名,不含扩展名

func GetFileName

func GetFileName(file string) string

GetFileName 获取路径中的文件名

func GetNextHalfHour

func GetNextHalfHour() time.Time

GetNextHalfHour 获取整点和半小时 例如: 当前是19:20, 则获取到的是19:30, 如果是19:40, 获取到的是20:00

func GetNextMinute

func GetNextMinute() time.Time

GetNextMinute 获取下一分钟时间戳

func GetProgramFileAbsPath

func GetProgramFileAbsPath() (string, error)

GetProgramFileAbsPath 获取当前可执行文件绝对路径

func GetProgramFileBaseName

func GetProgramFileBaseName() (string, error)

GetProgramFileBaseName 获取当前可执行文件名(不含扩展名)

func GetProgramFileName

func GetProgramFileName() (string, error)

GetProgramFileName 获取当前可执行文件名(含扩展名)

func GetTheDayBeginTime

func GetTheDayBeginTime(src time.Time, days int) (desc time.Time)

GetTheDayBeginTime 获取距离某时刻n天的开始时刻

func GetTheWeekBeginTime

func GetTheWeekBeginTime(src time.Time) (desc time.Time)

GetTheWeekBeginTime 获取某周周一0点0分0秒时刻

func GetThisMinute

func GetThisMinute() time.Time

GetThisMinute 获取这一分钟时间戳

func GetTypeName

func GetTypeName(i any) string

GetTypeName 获取接口中存放的实例的类型名

func IsDirOrFileExist

func IsDirOrFileExist(path string) error

IsDirOrFileExist 如果目录不存在创建指定目录

func IsSameDay

func IsSameDay(t1 time.Time, t2 time.Time) bool

func IsSameDayUnixTimeStamp

func IsSameDayUnixTimeStamp(t1 int64, t2 int64) bool

IsSameDayUnixTimeStamp 判断2个unix时间戳是不是同一天

func LoadJSONFile

func LoadJSONFile(file string, dst any) error

LoadJSONFile 加载JSON文件

func LowerFirst

func LowerFirst(str string) string

func MD5Sum

func MD5Sum(input []byte) (output []byte)

生成md串

func MD5Sumf

func MD5Sumf(format string, args ...any) (output []byte)

生成md串

func MakeSignalChannel

func MakeSignalChannel(sig ...os.Signal) chan os.Signal

func MkDir

func MkDir(path string) error

MkDir 如果目录不存在创建指定目录

func MustGetProgramFileAbsPath

func MustGetProgramFileAbsPath() string

MustGetProgramFileAbsPath 获取当前可执行文件绝对路径

func MustGetProgramFileBaseName

func MustGetProgramFileBaseName() string

MustGetProgramFileBaseName 获取当前可执行文件名(不含扩展名)

func MustGetProgramFileName

func MustGetProgramFileName() string

MustGetProgramFileName 获取当前可执行文件名(含扩展名)

func MustMkDir

func MustMkDir(path string)

MustMkDir 如果目录不存在创建指定目录

func ParseTimeString

func ParseTimeString(strTime string) (time.Time, error)

func ParseTimeStringByFormat

func ParseTimeStringByFormat(fmt string, strTime string) (time.Time, error)

ParseTimeStringByFormat 解析时间字符串, 返回UTC时间

func ParseTimeStringInLocation

func ParseTimeStringInLocation(strTime string) (time.Time, error)

func ParseTimeStringInLocationByFormat

func ParseTimeStringInLocationByFormat(fmt string, strTime string) (time.Time, error)

ParseTimeStringInLocationByFormat 解析时间字符串, 返回本地时间

func PutBuffer

func PutBuffer(b *bytes.Buffer)

func ReadLineFromConsole

func ReadLineFromConsole() (string, error)

func TruncateExtend

func TruncateExtend(file string) string

TruncateExtend 去掉文件扩展名

func UpperFirst

func UpperFirst(str string) string

func WaitExitSignal

func WaitExitSignal() os.Signal

func Walk

func Walk(dir string, extend string, whiteList []string, blackList []string, fn func(path string, info os.FileInfo, name string, isInBlackList bool) (continued bool)) (err error)

Walk 遍历目录

func Zip

func Zip(src []string, dest string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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