Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/// Print out 140 characters of random celebratory emoji.
package main
import (
"fmt"
"math/rand"
"time"
)
const NumberOfCharacters = 140
func randomItem(array []string) string {
max := len(array)
index := rand.Intn(max)
return array[index]
}
func main() {
// go's random number generator is deterministic by default, so if
// we want different celebrations on each run we're going to have
// to seed it.
rand.Seed(time.Now().UnixNano())
celebration := []string{"🎉", "✨", "🎊", "🎁", "👏🏽", "🙌🏽", "🍾"}
for count := 0; count < NumberOfCharacters; count++ {
fmt.Print(randomItem(celebration))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment