Search code examples
timergo

How to use Go's time.Tick?


I want to print something at intervals. But my code doesn't work, it throws an exception about deadlock.

Could you please help me with it? http://play.golang.org/p/pyEoXU-6Ee

func main() {
    c := time.Tick(1 * time.Minute)
    for now := range c {
        fmt.Printf("%v \n", now)
    }
}

Solution

  • Play.golang.org has some strict rules to protect it. If you run this locally, it works.