Skip to content

Instantly share code, notes, and snippets.

@fartbagxp
Created November 11, 2017 05:05
Show Gist options
  • Save fartbagxp/fce4b69c2c9efb9324e91568b1bda0d0 to your computer and use it in GitHub Desktop.
Save fartbagxp/fce4b69c2c9efb9324e91568b1bda0d0 to your computer and use it in GitHub Desktop.
Golang generate anonymize strings
func init() {
rand.Seed(time.Now().UnixNano())
}
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
func RandStringRunes(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
}
return string(b)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment