Skip to content

leaky-time-tick

Default severity: warning

Before Go 1.23, an unreferenced ticker could not be reclaimed unless it was stopped. Because time.Tick does not expose the ticker, returning functions should use time.NewTicker and stop it when they are finished.

Go 1.23 and newer can reclaim unreferenced tickers, so this check does not report projects targeting those versions. Tests, main packages, and endless functions are also accepted.

ticks := time.Tick(time.Second)
ticker := time.NewTicker(time.Second)
defer ticker.Stop()