xtools

package
v0.0.0-...-953156a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(str string) (string, error)

Base64Decode base64解密

func Base64Encode

func Base64Encode(str string) string

Base64Encode base64加密

func CRC32

func CRC32(data string) int64

CRC32

func Decomposition

func Decomposition(data int) []int

Decomposition 分解质因数

func FloatVal

func FloatVal(data string) (float64, bool)

FloatVal parse float

func GBKToUTF8

func GBKToUTF8(data string) (string, error)

GbkToUtf8 GbkToUtf8

func GCD

func GCD(data ...int) int

GCD 最大公约数

func GetMapVal

func GetMapVal(ac MapFunc) error

GetMapVal GetMapVal

func Guid

func Guid() string

Guid Guid

func Has

func Has(key interface{}, val ...interface{}) bool

Has 数组中包含是否包含查找的对象

func HashID

func HashID(id string, m int64) int64

HashID Hash

func IntVal

func IntVal(data string) (int64, bool)

IntVal parse int

func JSONMarshal

func JSONMarshal(dstr interface{}) string

JSONMarshal JsonToStr

func JSONToStr

func JSONToStr(dstr interface{}) string

JSONToStr JsonToStr

func MD5

func MD5(s string) string

MD5 对一个字符串进行MD5加密,不可解密

func MapToStruct

func MapToStruct(data map[string]string, out interface{}) error

MapToStruct MapToStruct

func MsTime

func MsTime() int64

MsTime 毫秒

func ObjectIDCounter

func ObjectIDCounter(w int) string

func RandID

func RandID(width int) string

RandID 随机ID

func Sha1

func Sha1(s string) string

Sha1 获取 SHA1 字符串

func Sleep

func Sleep(second time.Duration)

Sleep Sleep

func StructToMap

func StructToMap(obj interface{}) map[string]interface{}

StructToMap StructToMap

func StructToMapByTag

func StructToMapByTag(obj interface{}, tag string) map[string]interface{}

StructToMapByTag StructToMapByTag

func SubStr

func SubStr(str string, begin, length int) (substr string)

SubStr SubStr

func ToJSON

func ToJSON(dstr string, data interface{}) error

ToJson ToJson

func ToStr

func ToStr(dval interface{}) string

ToStr ToStr

func UTF8ToGBK

func UTF8ToGBK(data string) (string, error)

UTF8ToGBK UTF8ToGBK

func UpdateMap

func UpdateMap(ac MapFunc) error

UpdateMap UpdateMap

func UrlDecode

func UrlDecode(data string) map[string]string

UrlDecode UrlDecode

func UrlEncode

func UrlEncode(data map[string]string) string

UrlEncode UrlEncode

func Version

func Version() int64

Version 秒

func XSSHandleStruct

func XSSHandleStruct(data interface{}, tag string, field []string) error

XSSHandleStruct 对struct的指定字段进行xss过滤

Types

type AcLimiter

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

func NewAcLimiter

func NewAcLimiter(maxEvent int, expire time.Duration, tokennum int) *AcLimiter

func (*AcLimiter) Allow

func (h *AcLimiter) Allow(key string) bool

func (*AcLimiter) Allows

func (h *AcLimiter) Allows(key ...string) bool

type AcRate

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

func NewAcRate

func NewAcRate(sec int) *AcRate

func (*AcRate) Fail

func (h *AcRate) Fail()

func (*AcRate) Rate

func (h *AcRate) Rate() float64

func (*AcRate) SetKeyFunc

func (h *AcRate) SetKeyFunc(ac RateKeyFunc)

func (*AcRate) Succ

func (h *AcRate) Succ()

type ActionFunc

type ActionFunc func() error

type Breaker

type Breaker struct {
	CircuitRate float64 //熔断的成功率
	// contains filtered or unexported fields
}

type LazyHandler

type LazyHandler func(key ...string) (map[string]interface{}, error)

LazyHandler handler

type LazyTopics

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

LazyTopics topics

func NewTopics

func NewTopics(batch, goroutine int, action LazyHandler) *LazyTopics

NewTopics new lazy

func (*LazyTopics) Get

func (h *LazyTopics) Get(key string, d time.Duration) (interface{}, error)

Get get val

type LazyTopics2

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

LazyTopics topics

func NewTopics2

func NewTopics2(batch, goroutine int, action LazyHandler) *LazyTopics2

NewTopics new lazy

func (*LazyTopics2) Get

func (h *LazyTopics2) Get(key string, d time.Duration) (interface{}, error)

Get get val

type MapFunc

type MapFunc func() error

MapFunc UpdateMapFunc

type RateInter

type RateInter interface {
	Rate() float64
	Succ()
	Fail()
}

type RateKeyFunc

type RateKeyFunc func() interface{}

Jump to

Keyboard shortcuts

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