Standard library / time

time.Ticker.Stop()

Prevent further ticker sends without closing C. Coordinate receiver shutdown separately; do not range forever expecting Stop to close C. On Go 1.23, channel-timer rules depend on the main module go directive and GODEBUG=asynctimerchan; see compatibility notes. Expected stdout: 'stopped\n'.

Formal Syntax & Structure

go syntaxgo
func (t *Ticker) Stop()

Working Example

Example Snippetgo
package main
import (  "fmt"  "time")
func main() { ticker := time.NewTicker(time.Hour); ticker.Stop(); fmt.Println("stopped") }
Go Reference