Skip to content

Instantly share code, notes, and snippets.

@vharsh
Last active December 5, 2018 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vharsh/8c19bb6e04019b4595bfea24e2910924 to your computer and use it in GitHub Desktop.
Save vharsh/8c19bb6e04019b4595bfea24e2910924 to your computer and use it in GitHub Desktop.
the 10 seconds tick
package main
import "time"
import "fmt"
func ticks() {
ticker := time.NewTicker(10 * time.Second)
for t := range ticker.C {
fmt.Println("Tick at", t)
}
}
func main() {
go ticks()
// This program is able to make 9 ticks, from time ZERO
time.Sleep(100 * time.Second)
}
@vharsh
Copy link
Author

vharsh commented Dec 5, 2018

Tick at 2018-12-05 18:47:40.307927403 +0530 IST m=+10.000717989
Tick at 2018-12-05 18:47:50.307930067 +0530 IST m=+20.000720417
Tick at 2018-12-05 18:48:00.308006727 +0530 IST m=+30.000797355
Tick at 2018-12-05 18:48:10.307661384 +0530 IST m=+40.000452027
Tick at 2018-12-05 18:48:20.30798035 +0530 IST m=+50.000770996
Tick at 2018-12-05 18:48:30.308037877 +0530 IST m=+60.000828524
Tick at 2018-12-05 18:48:40.307500433 +0530 IST m=+70.000290771
Tick at 2018-12-05 18:48:50.307842194 +0530 IST m=+80.000632728
Tick at 2018-12-05 18:49:00.307486431 +0530 IST m=+90.000277015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment