tutils

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuncCost

func FuncCost(start time.Time, printer Printer)

FuncCost 获取函数的运行时间

func GetDayOffset

func GetDayOffset(tm time.Time, ago int64, format ...string) string

GetDayOffset 获取n天前或者后的时间

func GetDaysDiff

func GetDaysDiff(date1 time.Time, date2 time.Time) int

demo

func GetMonthByInt

func GetMonthByInt(weekDay string) int32

GetMonthByInt 获取每月返回为int值,1-12

func GetThisMonthFirstZeros

func GetThisMonthFirstZeros() int64

GetThisMonthFirstZeros 获取本月初时间戳

func GetWeekByIntDay

func GetWeekByIntDay(weekDay string) int32

GetWeekByIntDay 获取每周返回为int值,1-7

func RandStringBytesMask

func RandStringBytesMask(n int) string

RandStringBytesMask 获取N个随机字符串

func RunPeriod

func RunPeriod(interval time.Duration, handler func(), closeCh ...chan struct{})

RunPeriod 周期运行函数

func StringToTime

func StringToTime(t string, format ...string) time.Time

StringToTime 字符串转时间

func StringToUnix

func StringToUnix(t string, format ...string) int64

StringToUnix 字符串转换为时间戳

func TimeToString

func TimeToString(t time.Time, format ...string) string

TimeToString 时间转字符串

func TimeToUnix

func TimeToUnix(t time.Time) int64

TimeToUnix 时间转时间戳

func UnixToString

func UnixToString(tm int64, format ...string) string

UnixToString 时间戳转字符串

func UnixToTime

func UnixToTime(tm int64) time.Time

UnixToTime 时间戳转Time

Types

type EUnit

type EUnit[K any] struct {
	Raw   K
	Field []byte
}

func SortFieldsWithGbk

func SortFieldsWithGbk[K any](units []EUnit[K], offset int, limit int, desc bool) ([]EUnit[K], error)

SortFieldsWithGbk 按照中文排序

type Printer

type Printer func(time.Duration)

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result cmd exec result

func RunCmd

func RunCmd(cmdLine string, envs map[string]string, timeout ...time.Duration) *Result

RunCmd exec cmd and catch the result. Waits for the given command to finish with a timeout. If the command times out, it attempts to kill the process.

func (*Result) Error

func (r *Result) Error() error

Err returns the error log.

func (*Result) String

func (r *Result) String() string

String returns the exec log.

Jump to

Keyboard shortcuts

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