数据修改

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" "crypto/md5"
"encoding/hex" "encoding/hex"
"math" "math"
"math/rand"
"strings" "strings"
"sync" "sync"
"time"
) )
//安全锁 //安全锁
@ -111,35 +109,41 @@ func Md5(req string) string {
//随机数 //随机数
func Rand(count int) int { func Rand(count int) int {
//随机对象 res := Random()
var R = rand.New(rand.NewSource(time.Now().UnixNano()))
res := 0
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
res = res * 10 res = res * 10
res = res + R.Intn(10) }
if i == 0 && res == 0 { return ObjToInt(res)
for { }
res = res + R.Intn(10) func Random() float64 {
if res != 0 { 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 break
} }
m=m*0.1
} }
}
}
return res return v
} }
//随机数范围 //随机数范围
func RandX(small int, max int) int { func RandX(small int, max int) int {
res := 0 res := 0
//随机对象 //随机对象
var R = rand.New(rand.NewSource(time.Now().UnixNano()))
if small == max { if small == max {
return small return small
} }
for { for {
res = R.Intn(max) res = ObjToInt(Random()*float64(max+1))
if res >= small { if res >= small {
break break
} }