Documentation
¶
Index ¶
- func DeepClone(v interface{}) interface{}
- func DeepCopy(dst, src interface{})
- func DispatchReadPK(money float64, amount int, average bool) (pks []float64)
- func RandGroup(p ...uint32) int
- func RandInterval(b1, b2 int32) int32
- func RandIntervalN(b1, b2 int32, n uint32) []int32
- func RandString(len int) string
- type LimiterMap
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeepClone ¶
func DeepClone(v interface{}) interface{}
DeepClone v
Example ¶
package main
import (
"fmt"
"github.com/helloh2o/lucky/utils"
)
func main() {
src := []int{1, 2, 3}
dst := utils.DeepClone(src).([]int)
for _, v := range dst {
fmt.Println(v)
}
}
Output: 1 2 3
func DeepCopy ¶
func DeepCopy(dst, src interface{})
DeepCopy src to dst
Example ¶
package main
import (
"fmt"
"github.com/helloh2o/lucky/utils"
)
func main() {
src := []int{1, 2, 3}
var dst []int
utils.DeepCopy(&dst, &src)
for _, v := range dst {
fmt.Println(v)
}
}
Output: 1 2 3
func DispatchReadPK ¶
DispatchReadPK random || @average money/amount
func RandGroup ¶
RandGroup by []unit32
Example ¶
package main
import (
"fmt"
"github.com/helloh2o/lucky/utils"
)
func main() {
i := utils.RandGroup(0, 0, 50, 50)
switch i {
case 2, 3:
fmt.Println("ok")
}
}
Output: ok
func RandInterval ¶
RandInterval b1 to b2
Example ¶
package main
import (
"fmt"
"github.com/helloh2o/lucky/utils"
)
func main() {
v := utils.RandInterval(-1, 1)
switch v {
case -1, 0, 1:
fmt.Println("ok")
}
}
Output: ok
func RandIntervalN ¶
RandIntervalN b1, b2, n
Example ¶
package main
import (
"fmt"
"github.com/helloh2o/lucky/utils"
)
func main() {
r := utils.RandIntervalN(-1, 0, 2)
if r[0] == -1 && r[1] == 0 ||
r[0] == 0 && r[1] == -1 {
fmt.Println("ok")
}
}
Output: ok
Types ¶
type LimiterMap ¶
LimiterMap for limiter
var Limiter *LimiterMap
Limiter package lv default limiter
func (*LimiterMap) Add ¶
func (l *LimiterMap) Add(key interface{})
func (*LimiterMap) Del ¶
func (l *LimiterMap) Del(key interface{})
func (*LimiterMap) IsLimited ¶
func (l *LimiterMap) IsLimited(key interface{}, seconds int64) bool
func (*LimiterMap) UnSafeDel ¶
func (l *LimiterMap) UnSafeDel(key interface{})
Click to show internal directories.
Click to hide internal directories.