Last active
June 27, 2016 09:47
-
-
Save jgfrancisco/6cfabcb6aa1d38732de0 to your computer and use it in GitHub Desktop.
Random String Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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