util

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: GPL-3.0 Imports: 15 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(isAs bool, errMsg string)

Assert Assert boolean and output error message @Method Assert @Param (bool) false assert @Param (string) error message

func AssertEmpty

func AssertEmpty(isNull interface{}, errMsg string)

AssertEmpty Assert Nil and output an error message @Method AssertEmtpy @Param (interface{}) is null assert @Param (string) error message

func AssertError added in v1.1.0

func AssertError(err error)

AssertError Assert error is null

func GetCurrentGoroutineID

func GetCurrentGoroutineID() int

GetCurrentGoroutineID doc @Method GetCurrentGoroutineID @Summary Return the ID of the current coroutine @Return (int)

func GetStack

func GetStack() string

GetStack Return current stack information @Method GetStack @Return (string)

func IsDay added in v1.1.0

func IsDay(a time.Time, b time.Time) bool

IsDay 判断两时间段是否是同一天

func IsLittleEndian

func IsLittleEndian() bool

IsLittleEndian doc @Method IsLittleEndian @Summary Determine if the system is a small endian @Return (bool)

func JSONSerialize

func JSONSerialize(obj interface{}) string

JSONSerialize doc @Method JSONSerialize @Summary golang object Serialized to json string @Param (interface{}) json object @Return (string) json string

func JSONUnFormSerialize

func JSONUnFormSerialize(data string, v interface{}) error

JSONUnFormSerialize doc @Method JSONUnFormSerialize @Summary Reverse the json string into a golang object @Param (string) json string @Param (interface{}) out json object

func JSONUnSerialize

func JSONUnSerialize(data []byte, v interface{}) error

JSONUnSerialize doc @Method JSONUnSerialize @Summary Reverse the json string [byte] into a golang object @Param ([]byte) json []byte @Param (interface{}) out json object @Return (error)

func RandStr

func RandStr(length int) string

RandStr doc @Method RandStr doc : Randomly generate a string of length n @Param (int) length @Return (string)

func SpawnUUID

func SpawnUUID() string

SpawnUUID doc @Method SpawnUUID @Summary spawn uuid @Return (string) uuid

func SubStr

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

SubStr doc @Method SubStr @SummaryCut string ends with length @Param (string) source string @Param (int) start pos @Param (int) sub length @Return (string) sub string

func SubStr2

func SubStr2(str string, start int, end int) string

SubStr2 doc @Method SubStr2 doc : Cut string ends with index @Param (string) source string @Param (int) start pos @Param (int) end pos @Return (string) sub string

func Timestamp added in v1.1.0

func Timestamp() int64

Timestamp Returns 当前时间毫秒

func TimestampDay added in v1.1.0

func TimestampDay() int64

TimestampDay Returns 当前时间日时间间戳,用户潘盾是否是同一天

func TimestampFormat added in v1.1.0

func TimestampFormat() string

TimestampFormat Returns 当前时间字符串 @Summary get now time and format @Return (string) YYYY-MM-DD hh:ii:ss

func ToDate added in v1.1.0

func ToDate(tm string) time.Time

ToDate 字符串时间转换到 Time Date

func ToDateTime added in v1.1.0

func ToDateTime(tm string) time.Time

ToDateTime 字符串转换到 Time DateTime

func ToDay added in v1.1.0

func ToDay(tm time.Time) int64

ToDay 转换到时间戳(日)

func ToTimeFormat added in v1.1.0

func ToTimeFormat(t time.Time) string

ToTimeFormat Returns 时间转换为字符串

func ToTimeFormatPoint added in v1.1.0

func ToTimeFormatPoint(t *time.Time) string

func ToTimestamp added in v1.1.0

func ToTimestamp(t time.Time) int64

ToTimestamp Returns 返回这个时间的毫秒数

func ToTimestampPoint added in v1.1.0

func ToTimestampPoint(t *time.Time) int64

ToTimestampPoint Returns 返回这个时间的毫秒数

func VerifyAccountFormat

func VerifyAccountFormat(account string) bool

VerifyAccountFormat doc @Summary Verify account is valid @Param (string) account @Return (bool) is valid

func VerifyCaptchaFormat

func VerifyCaptchaFormat(captcha string) bool

VerifyCaptchaFormat doc @Summary Verify captcha is valid @Param (string) captcha @Return (bool) is valid

func VerifyEmailFormat

func VerifyEmailFormat(email string) bool

VerifyEmailFormat doc @Summary Verify is email @Param (string) email @Return (bool) is valid

func VerifyMobileFormat

func VerifyMobileFormat(mobileNum string) bool

VerifyMobileFormat doc @Summary Verify is mobile @Param (string) mobile @Return (bool) is valid

func VerifyPasswordFormat

func VerifyPasswordFormat(pwd string) bool

VerifyPasswordFormat doc @Summary Verify password is valid @Param (string) password @Return (bool) is valid

Types

type Application added in v1.1.0

type Application interface {
	Name() string
	Desc() string
	Open() (string, error)
	Close()
}

Application Daemon 服务对象接口

type Daemon added in v1.1.0

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

Daemon doc

func SpawnDaemon added in v1.1.0

func SpawnDaemon(app Application) *Daemon

SpawnDaemon 创建一个Daemon

func (*Daemon) Open added in v1.1.0

func (slf *Daemon) Open() (string, error)

Open 打开Daemon

type SensitiveMap

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

SensitiveMap filer/tire

func NewDFA

func NewDFA(words []string) *SensitiveMap

NewDFA create an sensitive map

func (*SensitiveMap) FindAll

func (slf *SensitiveMap) FindAll(text string) map[string]*Target

FindAll Return target

func (*SensitiveMap) FindOne

func (slf *SensitiveMap) FindOne(text string) (string, bool)

FindOne find first sensitive

type SignalWatch

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

SignalWatch doc @Struct SignalWatch @Summary signal watch proccesser

func (*SignalWatch) Initial

func (slf *SignalWatch) Initial(f func())

Initial doc @Method Initial @Summary Initialization signal watcher @Param (func()) Signal response back call function

func (*SignalWatch) Wait

func (slf *SignalWatch) Wait()

Wait doc @Method Wait @Summary wait signal watcher exit

func (*SignalWatch) Watch

func (slf *SignalWatch) Watch()

Watch doc @Method Watch @Summary start watch signal

type SnowFlake

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

SnowFlake doc @Summary snowflake object @Struct SnowFlake @Member int64 last stamp @Member int64 worker id @Member int64 data center id @Member int64 sequence @Member Mutex

func NewSnowFlake

func NewSnowFlake(workerID int64, id int64) *SnowFlake

NewSnowFlake doc @Summary new snowflake object @Method NewSnowFlake @Param int64 worker id @Param int64 id @Return *SnowFlake

func (*SnowFlake) NextID

func (slf *SnowFlake) NextID() (int64, error)

NextID doc @Summary spawn id @Method NextID @Return int64 id @Return error

type Target

type Target struct {
	Indexes []int
	Len     int
}

Target Find Sensitive group

Jump to

Keyboard shortcuts

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