tutils

package
v1.0.54 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 13 Imported by: 2

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 added in v1.0.1

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

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

func GetDaysDiff added in v1.0.1

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

demo

func GetMonthByInt added in v1.0.1

func GetMonthByInt(weekDay string) int32

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

func GetThisMonthFirstZeros added in v1.0.1

func GetThisMonthFirstZeros() int64

GetThisMonthFirstZeros 获取本月初时间戳

func GetWeekByIntDay added in v1.0.1

func GetWeekByIntDay(weekDay string) int32

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

func MemoryPage added in v1.0.41

func MemoryPage[T any](data []T, offset int64, limit int64) []T

MemoryPage 内存分页函数

func MustMarshal added in v1.0.32

func MustMarshal(value any) string

func RandStringBytesMask added in v1.0.21

func RandStringBytesMask(n int) string

RandStringBytesMask 获取N个随机字符串

func RunPeriod

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

RunPeriod 周期运行函数

func StringToTime added in v1.0.1

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

StringToTime 字符串转时间

func StringToUnix added in v1.0.1

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

StringToUnix 字符串转换为时间戳

func TimeToString added in v1.0.1

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

TimeToString 时间转字符串

func TimeToUnix added in v1.0.1

func TimeToUnix(t time.Time) int64

TimeToUnix 时间转时间戳

func UnixToString added in v1.0.1

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

UnixToString 时间戳转字符串

func UnixToTime added in v1.0.1

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 added in v1.0.16

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

Result cmd exec result

func RunCmd added in v1.0.16

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 added in v1.0.16

func (r *Result) Error() error

Error returns the error log.

func (*Result) String added in v1.0.16

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