Standard library / time
time.Timer.Reset()
Reschedule a timer. The bool reports whether it was active before reset. For AfterFunc, a false return may start another callback; coordinate overlap yourself. On Go 1.23, channel-timer rules depend on the main module go directive and GODEBUG=asynctimerchan; see compatibility notes. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (t *Timer) Reset(d Duration) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| d | Duration | Elapsed duration or interval. |
Return Value
bool
Reschedule a timer.
Working Example
Example Snippetgo
package main
import ( "fmt" "time")
func main() { timer := time.NewTimer(time.Hour) defer timer.Stop() fmt.Println(timer.Reset(0)) <-timer.C}