utils

package
v0.0.0-...-4f4919f Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

频率锁

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToString

func ConvertToString(src string, srcCode string, tagCode string) string

func CreateToken

func CreateToken(subject string, expire time.Duration) (string, error)

CreateToken 生成jwtToken

func DecrptogAES

func DecrptogAES(src, key string) string

func EncyptogAES

func EncyptogAES(src, key string) string

---------------DES加密 解密--------------------

func IdsFitter

func IdsFitter(ids []int) []int

func MD5

func MD5(value string) string

MD5 md5 encryption

func MustUtf8

func MustUtf8(s string) string

func PanicToError

func PanicToError(f func()) (err error)

PanicToError Panic转换为error

func PanicTrace

func PanicTrace(err interface{}) string

PanicTrace panic调用链跟踪

func ParseToken

func ParseToken(tokenString string) (string, error)

ParseToken 解析jwtToken

func PasswordHash

func PasswordHash(pwd string) string

密码生成

func PasswordVerify

func PasswordVerify(hashedPwd string, plainPwd string) bool

密码验证

func SuperConvert

func SuperConvert(fromStruct interface{}, toStruct interface{})

使用反射,转换结构体 仅支持单层级

func Validator

func Validator(err error) string

Types

type LockItem

type LockItem struct {
	Key      string
	LifeSpan time.Duration // 生命周期
	CreateOn time.Time     // 创建时间
}

type LockTable

type LockTable struct {
	sync.RWMutex
	CleanerDuraction time.Duration       // 触发定时清理器的时间
	Cleaner          *time.Timer         // 定时清理器
	Items            map[string]LockItem // 子集
}

func NewLockTable

func NewLockTable() *LockTable

func (*LockTable) IsLock

func (this *LockTable) IsLock(key string, lock_time time.Duration) bool

type SafeStringMap

type SafeStringMap struct {
	sync.RWMutex
	Map map[string]string
}

func NewSafeStringMap

func NewSafeStringMap() *SafeStringMap

func (*SafeStringMap) DEL

func (st *SafeStringMap) DEL(key string)

func (*SafeStringMap) GET

func (st *SafeStringMap) GET(key string) string

func (*SafeStringMap) SET

func (st *SafeStringMap) SET(key string, value string)

func (*SafeStringMap) SETNX

func (st *SafeStringMap) SETNX(key string, value string) bool

Jump to

Keyboard shortcuts

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