...
1 package main
2
3 import (
4 "fmt"
5 "math/rand"
6 "os"
7 "strconv"
8 "time"
9 )
10
11 var outQuote = "We've done the impossible, and that makes us mighty."
12 var errQuote = "Ah, curse your sudden but inevitable betrayal!"
13
14 var randomQuotes = []string{
15 "Can we maybe vote on the whole murdering people issue?",
16 "I swear by my pretty floral bonnet, I will end you.",
17 "My work's illegal, but at least it's honest.",
18 }
19
20 func main() {
21 fmt.Fprintln(os.Stdout, outQuote)
22 fmt.Fprintln(os.Stderr, errQuote)
23
24 randomIndex := rand.New(rand.NewSource(time.Now().UnixNano())).Intn(len(randomQuotes))
25
26 time.Sleep(100 * time.Millisecond)
27
28 fmt.Fprintln(os.Stdout, randomQuotes[randomIndex])
29
30 if len(os.Args) == 2 {
31 exitCode, _ := strconv.Atoi(os.Args[1])
32 os.Exit(exitCode)
33 } else {
34 os.Exit(randomIndex)
35 }
36 }
37
View as plain text