Standard library / time
time.Timer.Stop()
Prevent a pending timer from firing and report whether it was stopped while active. It does not close C or wait for an already running callback. On Go 1.23, channel-timer rules depend on the main module go directive and GODEBUG=asynctimerchan; see compatibility notes. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
func (t *Timer) Stop() boolReturn Value
bool
Prevent a pending timer from firing and report whether it was stopped while active.
Working Example
Example Snippetgo
package main
import ( "fmt" "time")
func main() { timer := time.NewTimer(time.Hour); fmt.Println(timer.Stop(), timer.Stop()) }