summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/theo/main.go2
-rw-r--r--theo.go12
2 files changed, 8 insertions, 6 deletions
diff --git a/cmd/theo/main.go b/cmd/theo/main.go
index 25a5cb5..12ec5e4 100644
--- a/cmd/theo/main.go
+++ b/cmd/theo/main.go
@@ -7,5 +7,5 @@ import (
)
func main() {
- fmt.Println(theo.Quote())
+ fmt.Println(theo.Random())
}
diff --git a/theo.go b/theo.go
index b0e7d95..6b455d0 100644
--- a/theo.go
+++ b/theo.go
@@ -11,7 +11,8 @@ import (
"time"
)
-var talk = []string{
+// Talk contains known quotes
+var Talk = []string{
`Write more code.`,
`Make more commits.`,
`That's because you have been slacking.`,
@@ -127,12 +128,13 @@ var talk = []string{
`All that complexity stopped us from getting flying cars by today.`,
}
-func init() {
+// Random quote
+func Random() string {
rand.Seed(time.Now().UnixNano())
+ return Talk[rand.Intn(len(Talk))]
}
-// Quote returns random quote
+// Quote for backward compatibility, use Random instead
func Quote() string {
- n := rand.Intn(len(talk))
- return talk[n]
+ return Random()
}