Skip to content

Instantly share code, notes, and snippets.

@jgfrancisco
Last active June 27, 2016 09:47
Show Gist options
  • Save jgfrancisco/6cfabcb6aa1d38732de0 to your computer and use it in GitHub Desktop.
Save jgfrancisco/6cfabcb6aa1d38732de0 to your computer and use it in GitHub Desktop.
Random String Generator
import (
"math/rand"
)
var chars = []rune(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
func randString(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = chars[rand.Intn(len(chars))]
}
return string(b)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment