Documentation ¶
Index ¶
- Variables
- func Caller() (name string)
- func FuncTrace(xl *log.Logger) func()
- func NewRandomChars(length int, chars []byte) (s string)
- func NewRandomNumber(length int) string
- func NewRandomStr(length int) string
- func Truncate(str string, limit int) string
- func WithRetry(f func() error)
- func WithRetryTimesInterval(f func() error, times, intervalSec int)
- func WithShortRetry(f func() error)
- type SecurityMap
- func (sm *SecurityMap) Edit(key string, fn func(key string, value interface{}) (interface{}, error)) error
- func (sm *SecurityMap) Get(key string) (value interface{})
- func (sm *SecurityMap) Has(key string) bool
- func (sm *SecurityMap) Range(fn func(key string, value interface{}) bool)
- func (sm *SecurityMap) Set(key string, value interface{})
Constants ¶
This section is empty.
Variables ¶
View Source
var StdChars = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
StdChars standard characters allowed in uniuri string.
View Source
var StdNumbers = []byte("0123456789")
StdNumbers base random numbers
Functions ¶
func Caller ¶
func Caller() (name string)
Caller 返回上一层调用者的函数信息 例如:
func abc() { Caller() 这里就会返回 abc }
func NewRandomChars ¶
NewRandomChars returns a new random string of the provided length, consisting of the provided byte slice of allowed characters (maximum 256).
func NewRandomNumber ¶
NewRandomNumber return a random number string
func NewRandomStr ¶
NewRandomStr returns a new random string of the provided length, consisting of standard characters.
func WithRetry ¶
func WithRetry(f func() error)
WithRetry 执行某个函数,如果返回错误,那么在 10 分钟内重复执行,每执行一次,sleep 的时间左移一位
func WithRetryTimesInterval ¶
WithRetryTimesInterval 重试
func WithShortRetry ¶
func WithShortRetry(f func() error)
WithShortRetry 执行某个函数,如果返回错误,那么2s 后重试, 重试5次
Types ¶
type SecurityMap ¶
type SecurityMap struct {
// contains filtered or unexported fields
}
func NewSecurityMap ¶
func NewSecurityMap() *SecurityMap
func (*SecurityMap) Edit ¶
func (sm *SecurityMap) Edit(key string, fn func(key string, value interface{}) (interface{}, error)) error
func (*SecurityMap) Get ¶
func (sm *SecurityMap) Get(key string) (value interface{})
func (*SecurityMap) Has ¶
func (sm *SecurityMap) Has(key string) bool
func (*SecurityMap) Range ¶
func (sm *SecurityMap) Range(fn func(key string, value interface{}) bool)
func (*SecurityMap) Set ¶
func (sm *SecurityMap) Set(key string, value interface{})
Click to show internal directories.
Click to hide internal directories.