summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-08-17 06:54:45 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-08-17 06:54:45 +0200
commit05e44aa867b85303e21136f9eed9e99923f9bdf0 (patch)
treee768fb4b5ea94531bc115355319bfe1245b99967
parent78aafbd792f19b2c6ef71b4624dc7129c73b26df (diff)
Export Talk
-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()
}