This commit is contained in:
Mark McGranaghan
2012-09-23 11:33:17 -07:00
parent fd67d524c1
commit 5c8ddea5ff
12 changed files with 105 additions and 88 deletions

View File

@@ -1,15 +0,0 @@
package main
import ("time"; "fmt")
func main() {
ticker := time.NewTicker(time.Millisecond * 500)
go func() {
for t := range ticker.C {
fmt.Println("Tick at", t)
}
}()
time.Sleep(time.Millisecond * 1500)
ticker.Stop()
fmt.Println("Ticker stopped")
}

18
090-tickers/tickers.go Normal file
View File

@@ -0,0 +1,18 @@
// ## Tickers
package main
import "time"
import "fmt"
func main() {
ticker := time.NewTicker(time.Millisecond * 500)
go func() {
for t := range ticker.C {
fmt.Println("Tick at", t)
}
}()
time.Sleep(time.Millisecond * 1500)
ticker.Stop()
fmt.Println("Ticker stopped")
}

5
090-tickers/tickers.sh Normal file
View File

@@ -0,0 +1,5 @@
$ go run tickers.go
Tick at 2012-09-23 11:29:56.487625 -0700 PDT
Tick at 2012-09-23 11:29:56.988063 -0700 PDT
Tick at 2012-09-23 11:29:57.488076 -0700 PDT
Ticker stopped