Share & grow the world's code base!

Delve into a community where programmers unite to discover code snippets, exchange skills, and enhance their programming proficiency. With abundant resources and a supportive community, you'll find everything essential for your growth and success.

Example of using Go timers

Timers allow you to execute one event in the future. You tell the timer how long you want to wait and it provides a channel to be notified at that time. The first timer will wait for 3 seconds. <-firstTimer.C blocks the timer C channel until a message (current time) is sent indicating that the timer has expired. If you just want to wait, you can use time.Sleep. One reason a timer can be useful is that you can cancel the timer before it expires. The first timer expires 3s after the program starts, but the second is stopped before it expires.