mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
fix: genRandomString
This commit is contained in:
+7
-3
@@ -16,6 +16,10 @@ var Functions = map[string]interface{}{
|
|||||||
"md5": MD5,
|
"md5": MD5,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
}
|
||||||
|
|
||||||
func getTimestamp() int64 {
|
func getTimestamp() int64 {
|
||||||
return time.Now().UnixNano() / int64(time.Millisecond)
|
return time.Now().UnixNano() / int64(time.Millisecond)
|
||||||
}
|
}
|
||||||
@@ -24,10 +28,10 @@ func sleep(nSecs int) {
|
|||||||
time.Sleep(time.Duration(nSecs) * time.Second)
|
time.Sleep(time.Duration(nSecs) * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
func genRandomString(n int) string {
|
const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
||||||
const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
|
||||||
const lettersLen = len(letters)
|
|
||||||
|
|
||||||
|
func genRandomString(n int) string {
|
||||||
|
lettersLen := len(letters)
|
||||||
b := make([]byte, n)
|
b := make([]byte, n)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
b[i] = letters[rand.Intn(lettersLen)]
|
b[i] = letters[rand.Intn(lettersLen)]
|
||||||
|
|||||||
Reference in New Issue
Block a user