utils

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 22 Imported by: 4

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 Contains

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

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

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 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 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