utils

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeFormat     = "2006-01-02 15:04:05"
	TimeFormatZero = "0001-01-01 00:00:00"
)
View Source
const (
	REGX_ID_PATTERN_15 = "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$"
	REGX_ID_PATTERN_18 = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9]|X)$"
)

Variables

This section is empty.

Functions

func AppendInt

func AppendInt(list []int, target int, ifAbsent bool) []int

func AppendInt64

func AppendInt64(list []int64, target int64, ifAbsent bool) []int64

func AppendStr

func AppendStr(list []string, target string, ifAbsent bool) []string

func Contains

func Contains(obj interface{}, target interface{}) bool

判断obj是否在target中,target支持的类型arrary,slice,map

func Contains2

func Contains2(obj interface{}, target interface{}) bool

func CurrentTimeMillis

func CurrentTimeMillis() int64

func GenerateCode

func GenerateCode(size int) string

func GetGID

func GetGID() uint64

func GetStringParamsMapFromUrl

func GetStringParamsMapFromUrl(paramsStr string) map[string]string

func GetValidDate

func GetValidDate(validTime time.Duration) time.Time

func IsIdNoCorrect

func IsIdNoCorrect(idNo string) bool

func LocalIP

func LocalIP() string

func Marshal

func Marshal(obj interface{}) ([]byte, error)

func MarshalToString

func MarshalToString(obj interface{}) (string, error)

func Mask

func Mask(str string, before int, after int) string

func NewOptions

func NewOptions(config cc.IConfig, opts interface{})

func ReadFile

func ReadFile(localFile string) ([]byte, error)

func RemoveDuplicateInt

func RemoveDuplicateInt(list []int) []int

func RemoveDuplicateInt64

func RemoveDuplicateInt64(list []int64) []int64

func RemoveDuplicateStr

func RemoveDuplicateStr(list []string) []string

func SubStr

func SubStr(str string, start int, length int) (result string)

截取字符串,支持多字节字符 start:起始下标,负数从从尾部开始,最后一个为-1 length:截取长度,负数表示截取到末尾

func Unmarshal

func Unmarshal(bytes []byte, obj interface{}) error

func UnmarshalFromString

func UnmarshalFromString(str string, obj interface{}) error

func Uuid

func Uuid() string

func VerifyEmailFormat

func VerifyEmailFormat(email string) bool

Types

type DateTime

type DateTime struct {
	Time time.Time
}

func (DateTime) Format

func (t DateTime) Format() string

func (DateTime) IsZero

func (t DateTime) IsZero() bool

func (DateTime) MarshalJSON

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

func (*DateTime) Scan

func (t *DateTime) Scan(value interface{}) error

func (DateTime) String

func (t DateTime) String() string

func (*DateTime) UnmarshalJSON

func (t *DateTime) UnmarshalJSON(b []byte) error

func (DateTime) Value

func (t DateTime) Value() (driver.Value, error)

type Error

type Error struct {
	Err     error
	Msginfo *response.Msginfo
}

func NewError

func NewError(err error, msginfo *response.Msginfo) *Error

func (*Error) Error

func (e *Error) Error() string

type MDecimal

type MDecimal struct {
	decimal.Decimal
}

func NewFromFloat

func NewFromFloat(value float64) MDecimal

func NewFromFloat32

func NewFromFloat32(value float32) MDecimal

func NewFromInt

func NewFromInt(value int64) MDecimal

func NewFromInt32

func NewFromInt32(value int32) MDecimal

func NewFromString

func NewFromString(value string) (MDecimal, error)

func (MDecimal) MarshalJSON

func (d MDecimal) MarshalJSON() ([]byte, error)

type Worker

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

定义一个woker工作节点所需要的基本参数

func NewWorkerWithRedis

func NewWorkerWithRedis(r *redis.RedisClient, appName string) (*Worker, error)

func (*Worker) GetId

func (w *Worker) GetId() string

* @desc 获取id @auth jerry.shi 2021-05-24

func (*Worker) GetIdWithPrefix

func (w *Worker) GetIdWithPrefix(prefix string) string

func (*Worker) Now

func (w *Worker) Now() int64

* @desc 获取当前时间 @auth liuguoqiang 2020-06-16 @param @return

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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