From 05e44aa867b85303e21136f9eed9e99923f9bdf0 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 17 Aug 2016 06:54:45 +0200 Subject: Export Talk --- cmd/theo/main.go | 2 +- theo.go | 12 +++++++----- 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() } -- cgit v1.2.3