utils

package
v0.6.18 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 19 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 AppendInt added in v0.2.13

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

func AppendInt64 added in v0.2.13

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

func AppendStr added in v0.2.13

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 added in v0.2.21

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

func CurrentTimeMillis

func CurrentTimeMillis() int64

func GenerateCode

func GenerateCode(size int) string

func GetAgeFromIdNum added in v0.6.17

func GetAgeFromIdNum(idNum string) int

身份证号获取年龄

func GetAgeFromIdNumEndTime added in v0.6.17

func GetAgeFromIdNumEndTime(idNum string, endTime time.Time) int

身份证号获取到某一时间点年龄

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 added in v0.2.13

func RemoveDuplicateInt(list []int) []int

func RemoveDuplicateInt64 added in v0.2.13

func RemoveDuplicateInt64(list []int64) []int64

func RemoveDuplicateStr added in v0.2.13

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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