Skip to content

Instantly share code, notes, and snippets.

@se77en se77en/random_string.go
Last active Aug 29, 2015

What would you like to do?
random string in Go
func randomString(size int) string {
alpha = `abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789` //better to define a const
buf := make([]byte, size)
for i := 0; i < size; i++ {
buf[i] = alpha[rand.Intn(len(alpha))]
return string(buf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.