Skip to content

Instantly share code, notes, and snippets.

@maurobaraldi
Created January 3, 2018 20:06
Show Gist options
  • Save maurobaraldi/4ec957f354e84429eb9315a4f9466bea to your computer and use it in GitHub Desktop.
Save maurobaraldi/4ec957f354e84429eb9315a4f9466bea to your computer and use it in GitHub Desktop.
A pet name generator in Go
package main
import (
"fmt"
"math/rand"
"time"
)
var first = [31]string{
"Asog",
"Bagar",
"Banag",
"Bebar",
"Chabug",
"Coqen",
"Dayer",
"Degen",
"Domar",
"Gegar",
"Golag",
"Gurum",
"Kagor",
"Kaimar",
"Laiyor",
"Leten",
"Maqen",
"Medog",
"Napug",
"Naqen",
"Nayag",
"Qeqen",
"Rimar",
"Rusar",
"Rutog",
"Sanor",
"Xagar",
"Xoisar",
"Zamar",
"Zapug",
"Zigar",
}
var second = [31]string{
"Bekasi",
"Cilegon",
"Cimahi",
"Cirebon",
"Kediri",
"Magelang",
"Mojokerto",
"Pasuruan",
"Pekalongan",
"Probolinggo",
"Salatiga",
"Semarang",
"Sukabumi",
"Surabaya",
"Surakarta",
"Tasikmalaya",
"Palangkaraya",
"Samarinda",
"Tarakan",
"Tidore",
"Mataram",
"Jayapura",
"Kotamobagu",
"Manado",
"Palopo",
"Tomohon",
"Gunungsitoli",
"Lhokseumawe",
"Payakumbuh",
"Pematang",
"Prabumulih",
}
func Choice(array [31]string) string {
return array[rand.Intn(len(array))]
}
func GenerateName() string {
rand.Seed(time.Now().Unix())
return fmt.Sprintf("%s %s", Choice(first), Choice(second))
}
func main() {
fmt.Println(GenerateName())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment