MCPcopy
hub / github.com/semaphoreui/semaphore / rnd

Function rnd

pkg/random/string.go:13–24  ·  view source on GitHub ↗
(strlen int, baseStr string)

Source from the content-addressed store, hash-verified

11)
12
13func rnd(strlen int, baseStr string) string {
14 result := make([]byte, strlen)
15 charLen := big.NewInt(int64(len(baseStr)))
16 for i := range result {
17 r, err := rand.Int(rand.Reader, charLen)
18 if err != nil {
19 panic(err)
20 }
21 result[i] = baseStr[r.Int64()]
22 }
23 return string(result)
24}
25
26func Number(strlen int) string {
27 return rnd(strlen, digits)

Callers 2

NumberFunction · 0.85
StringFunction · 0.85

Calls 1

int64Function · 0.50

Tested by

no test coverage detected