Documentation ¶
Index ¶
- func Abs(n int32) uint32
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(s int) (string, error)
- func HmacSha1(content []byte, key []byte) string
- func HmacSha256(content []byte, key []byte) string
- func HmacSha256ByString(contentstr string, keystr string) string
- func RandBetween(min, max int) int
- func RandWeight(weight []uint32) uint32
- func RandWeightStruct(weight []UtilWeightInterface) interface{}
- func SliceOutOfOrder(in []string) []string
- func SliceOutOfOrderByInt(in []uint64) []uint64
- type UtilWeightInterface
- type ValueWeightPair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which GenerateRandomBytes case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which GenerateRandomString case the caller should not continue.
func HmacSha256ByString ¶
HmacSha256ByString func
func RandWeightStruct ¶
func RandWeightStruct(weight []UtilWeightInterface) interface{}
RandWeightStruct 根据权重列表随机出一个结果,返回命中下标
func SliceOutOfOrderByInt ¶
SliceOutOfOrderByInt 乱序切片
Types ¶
type UtilWeightInterface ¶
type UtilWeightInterface interface {
GetWeight() uint32
}
UtilWeightInterface infterface
type ValueWeightPair ¶
type ValueWeightPair struct {
// contains filtered or unexported fields
}
ValueWeightPair 权值对,根据权重随机一个值出来
func NewValueWeightPair ¶
func NewValueWeightPair() *ValueWeightPair
NewValueWeightPair new value weight pair
func (*ValueWeightPair) Add ¶
func (v *ValueWeightPair) Add(weight uint32, value uint64)
Add add weight