Skip to content

leaky-time-tick

Detect time.Tick calls that leak on older Go versions.

Updated View as Markdown

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.

Bad

ticks := time.Tick(time.Second)

Good

ticker := time.NewTicker(time.Second)
defer ticker.Stop()
Navigation

Type to search…

↑↓ navigate↵ selectEsc close