mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-16 10:07:36 +08:00
feat: call function with one argument
This commit is contained in:
@@ -1,11 +1,26 @@
|
||||
package builtin
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
var Functions = map[string]interface{}{
|
||||
"sleep": Sleep,
|
||||
"sleep": sleep,
|
||||
"gen_random_string": genRandomString,
|
||||
}
|
||||
|
||||
func Sleep(nSecs int) {
|
||||
func sleep(nSecs int) {
|
||||
time.Sleep(time.Duration(nSecs) * time.Second)
|
||||
}
|
||||
|
||||
func genRandomString(n int) string {
|
||||
const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
||||
const lettersLen = len(letters)
|
||||
|
||||
b := make([]byte, n)
|
||||
for i := range b {
|
||||
b[i] = letters[rand.Intn(lettersLen)]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user