tools

package
v1.4.26 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: GPL-3.0 Imports: 15 Imported by: 5

Documentation

Index

Constants

View Source
const (
	B  Byte = 1
	KB      = 1024 * B
	MB      = 1024 * KB
	GB      = 1024 * MB
	TB      = 1024 * GB
)
View Source
const (
	SecondsPerDay       = 24 * 60 * 60
	Day                 = 24 * time.Hour
	StdTimeLayout       = "2006-01-02 15:04:05.000"
	StdTimeSimpleLayout = "2006-1-2 15:4:5"
	StdDateFormat       = "2006-01-02"
)

Variables

View Source
var (
	TimeZero       = time.Unix(0, 0)
	TimeOffset     int64
	TimeOffsetPath = "./.timeoffset"
)

Functions

func GenRSAKey added in v1.2.20

func GenRSAKey() error

func ModifyTimeOffset added in v1.1.4

func ModifyTimeOffset(add int64)

func NextIntervalTime

func NextIntervalTime(t time.Time, intervalSeconds int) time.Time

NextIntervalTime 以当天开始时间为初始值 间隔 intervalSeconds触发一次,返回下次触发的时间

func Now

func Now() time.Time

func RSAPrivateDecrypt added in v1.2.20

func RSAPrivateDecrypt(key, ciphertext []byte) ([]byte, error)

RSAPrivateDecrypt 私钥解密

func RSAPublicKeyEncrypt added in v1.2.20

func RSAPublicKeyEncrypt(key, data []byte) ([]byte, error)

RSAPublicKeyEncrypt 公钥加密

func TimeFormat

func TimeFormat(data time.Time) string

func TimeParse

func TimeParse(data string) time.Time

func Try

func Try(fn func(), catch ...func(ex interface{}))

func UUID

func UUID() string

func XUID added in v1.2.13

func XUID() string

Types

type Byte added in v1.2.21

type Byte = uint64

type EnumIdx added in v1.2.0

type EnumIdx struct {
	PackageName string
	Prefix      string
	Enum2Name   map[int32]string
	Name2Enum   map[string]int32
}

type GetProtoByName added in v1.2.0

type GetProtoByName func(name string) (interface{}, bool)

type ProtoIndex added in v1.2.0

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

func NewProtoIndex added in v1.2.0

func NewProtoIndex(f GetProtoByName, enum EnumIdx) *ProtoIndex

func (*ProtoIndex) FindMsgByName added in v1.2.0

func (s *ProtoIndex) FindMsgByName(msgName string) (proto.Message, bool)

func (*ProtoIndex) MsgIdToName added in v1.2.0

func (s *ProtoIndex) MsgIdToName(msgId int32) (msgName string, ok bool)

func (*ProtoIndex) MsgName added in v1.2.0

func (s *ProtoIndex) MsgName(msg proto.Message) string

func (*ProtoIndex) MsgNameToId added in v1.2.0

func (s *ProtoIndex) MsgNameToId(msgName string) (msgId int32, ok bool)

func (*ProtoIndex) UnmarshalPbMsg added in v1.2.0

func (s *ProtoIndex) UnmarshalPbMsg(msgId int32, data []byte) proto.Message

type TimeEx added in v1.4.0

type TimeEx struct {
	time.Time
}

func NewTimeEx added in v1.4.0

func NewTimeEx(tm ...time.Time) TimeEx

func (TimeEx) BeginOfHour added in v1.4.0

func (t TimeEx) BeginOfHour() time.Time

BeginOfHour 当前小时的起点

func (TimeEx) BeginOfMinute added in v1.4.0

func (t TimeEx) BeginOfMinute() time.Time

func (TimeEx) BeginOfToday added in v1.4.0

func (t TimeEx) BeginOfToday() time.Time

BeginOfToday 当日0点

func (TimeEx) DateTime added in v1.4.0

func (t TimeEx) DateTime() time.Time

func (TimeEx) EndOfMonthly added in v1.4.0

func (t TimeEx) EndOfMonthly() time.Time

EndOfMonthly 获取本月最后一天的0点

func (TimeEx) EndOfToday added in v1.4.0

func (t TimeEx) EndOfToday() time.Time

EndOfToday 当日24点

func (TimeEx) EndOfWeek added in v1.4.0

func (t TimeEx) EndOfWeek() time.Time

EndOfWeek 获取本周周日0点

func (TimeEx) NextHour added in v1.4.0

func (t TimeEx) NextHour() time.Time

func (TimeEx) StartOfMonthly added in v1.4.0

func (t TimeEx) StartOfMonthly() time.Time

StartOfMonthly 获取本月第一天0点

func (TimeEx) StartOfWeek added in v1.4.0

func (t TimeEx) StartOfWeek() time.Time

StartOfWeek 获取本周周一0点

Jump to

Keyboard shortcuts

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