Last active
January 18, 2018 04:04
-
-
Save p4tin/178792d020dfffb83e61c6be0b53ba01 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package main | |
import ( | |
"math/rand" | |
"time" | |
) | |
func init() { | |
rand.Seed(time.Now().UnixNano()) | |
} | |
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") | |
func GetSlug(n int) string { | |
b := make([]rune, n) | |
for i := range b { | |
b[i] = letterRunes[rand.Intn(len(letterRunes))] | |
} | |
return string(b) | |
} | |
func main() { | |
rand.Seed(time.Now().UTC().UnixNano()) | |
slug := GetSlug(8) | |
println(slug) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment