Home

Published

- 1 min read

random string go

img of random string go

The solution for this is noted below

random string go

Solution

   const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

func RandStringBytes(n int) string {
    b := make([]byte, n)
    for i := range b {
        b[i] = letterBytes[rand.Intn(len(letterBytes))]
    }
    return string(b)
}

Try other methods by searching on the site. That is if this doesn’t work