Introduction
This challenge focuses on the use of timers and tickers in Golang. Timers and tickers are useful for executing code at a specific time or repeatedly at a given interval.
This challenge focuses on the use of timers and tickers in Golang. Timers and tickers are useful for executing code at a specific time or repeatedly at a given interval.
The challenge requires the implementation of a timer that waits for a specified duration and then fires. Additionally, the timer should be cancellable before it fires.
time
package should be imported.// The first timer will fire ~2s after we start the
// program, but the second should be stopped before it has
// a chance to fire.
$ go run timers.go
Timer 1 fired
Timer 2 stopped
This challenge demonstrated the use of timers in Golang. Timers can be used to execute code at a specific time or to wait for a specified duration before executing code. Additionally, timers can be cancelled before they fire.