Skip to content

Instantly share code, notes, and snippets.

@chiliec
Created July 9, 2020 18:04
Show Gist options
  • Save chiliec/60d815bcbfc56ff62fafe2ff8ce80f6b to your computer and use it in GitHub Desktop.
Save chiliec/60d815bcbfc56ff62fafe2ff8ce80f6b to your computer and use it in GitHub Desktop.
Get random emoji in GoLang
// (c) 2020 Vladimir Babin
// This code is licensed under MIT license.
func randomEmoji() string {
rand.Seed(time.Now().UnixNano())
// http://apps.timwhitlock.info/emoji/tables/unicode
emoji := [][]int{
// Emoticons icons
{128513, 128591},
// Transport and map symbols
{128640, 128704},
}
r := emoji[rand.Int()%len(emoji)]
min := r[0]
max := r[1]
n := rand.Intn(max-min+1) + min
return html.UnescapeString("&#" + strconv.Itoa(n) + ";")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment