aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..0b7a3a1
--- /dev/null
+++ b/main.go
@@ -0,0 +1,36 @@
+package main
+
+import (
+ "fmt"
+ "math/rand"
+ "os"
+ "os/signal"
+ "time"
+)
+
+func main() {
+ hi := []string{"Hello", "Hola", "Bonjour",
+ "Ciao", "こんにちは", "안녕하세요",
+ "Cześć", "Olá", "Здравствуйте",
+ "Chào bạn", "您好", "Hallo"}
+
+ fmt.Printf("Saying hello in up to %d languages! \n", len(hi))
+
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, os.Interrupt)
+
+ tick := time.NewTicker(1 * time.Second)
+ for {
+ select {
+ case <-tick.C:
+ r := rand.Intn(len(hi))
+ fmt.Println(hi[r])
+ case <-c:
+ // Got a Ctrl-C
+ fmt.Println("Exiting!")
+ os.Exit(0)
+ default:
+ time.Sleep(300 * time.Millisecond)
+ }
+ }
+}