MCPcopy Create free account
hub / github.com/ddd/gpb / randomString

Function randomString

tools/bg_gen/main.go:21–29  ·  view source on GitHub ↗

Function to generate a random string of specified length

(length int)

Source from the content-addressed store, hash-verified

19
20// Function to generate a random string of specified length
21func randomString(length int) string {
22 const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
23 seededRand := rand.New(rand.NewSource(time.Now().UnixNano()))
24 b := make([]byte, length)
25 for i := range b {
26 b[i] = charset[seededRand.Intn(len(charset))]
27 }
28 return string(b)
29}
30
31// Function to generate a random 7-digit number as string
32func randomPhoneDigits() string {

Callers 1

generateBgTokenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected