数据修改

This commit is contained in:
hoteas 2018-01-07 16:05:32 +00:00
parent 2a0d84a86b
commit 9bb522d7a0

34
func.go
View File

@ -4,10 +4,8 @@ import (
"crypto/md5"
"encoding/hex"
"math"
"math/rand"
"strings"
"sync"
"time"
)
//安全锁
@ -111,35 +109,41 @@ func Md5(req string) string {
//随机数
func Rand(count int) int {
//随机对象
var R = rand.New(rand.NewSource(time.Now().UnixNano()))
res := 0
res := Random()
for i := 0; i < count; i++ {
res = res * 10
res = res + R.Intn(10)
if i == 0 && res == 0 {
for {
res = res + R.Intn(10)
if res != 0 {
}
return ObjToInt(res)
}
func Random() float64 {
v:=float64(0);
m:=float64(0.1);
for i:=0;i<15;i++{
facter:=map[int]int{0:1,9:1,2:1,7:1,4:1,5:1,6:1,3:1,8:1,1:1}
for k,_:= range facter{
v=v+float64(k)*m
break
}
m=m*0.1
}
}
}
return res
return v
}
//随机数范围
func RandX(small int, max int) int {
res := 0
//随机对象
var R = rand.New(rand.NewSource(time.Now().UnixNano()))
if small == max {
return small
}
for {
res = R.Intn(max)
res = ObjToInt(Random()*float64(max+1))
if res >= small {
break
}