package main import ( "fmt" "math/rand" "time" ) type affirmative string func (m affirmative) String() string { return "[+] " + string(m) } type nonCommittal string func (m nonCommittal) String() string { return "[?] " + string(m) } type negative string func (m negative) String() string { return "[-] " + string(m) } type magic []fmt.Stringer func (m magic) String() string { rand.Seed(time.Now().UnixNano()) n := rand.Intn(len(m)) return m[n].String() } var fortune = magic{ // affirmative affirmative("It is certain."), affirmative("It is decidedly so."), affirmative("Without a doubt."), affirmative("Yes - definitely."), affirmative("You may rely on it."), affirmative("As I see it, yes."), affirmative("Most likely."), affirmative("Outlook good."), affirmative("Yes."), affirmative("Signs point to yes."), // non-committal nonCommittal("Reply hazy, try again."), nonCommittal("Ask again later."), nonCommittal("Better not tell you now."), nonCommittal("Cannot predict now."), nonCommittal("Concentrate and ask again."), // negative negative("Don't count on it."), negative("My reply is no."), negative("My sources say no."), negative("Outlook not so good."), negative("Very doubtful."), } func main() { fmt.Println(fortune) }