forked from chronosphereio/calyptia-flog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
random.go
32 lines (27 loc) · 699 Bytes
/
random.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"math/rand"
"net/url"
"strings"
"github.com/brianvoe/gofakeit"
)
// RandResourceURI generates a random resource URI
func RandResourceURI() string {
var uri string
num := gofakeit.Number(1, 4)
for i := 0; i < num; i++ {
uri += "/" + url.QueryEscape(gofakeit.BS())
}
uri = strings.ToLower(uri)
return uri
}
// RandAuthUserID generates a random auth user id
func RandAuthUserID() string {
candidates := []string{"-", strings.ToLower(gofakeit.Username())}
return candidates[rand.Intn(2)]
}
// RandHTTPVersion returns a random http version
func RandHTTPVersion() string {
versions := []string{"HTTP/1.0", "HTTP/1.1", "HTTP/2.0"}
return versions[rand.Intn(3)]
}