time.Tick is called in a function that returns, which leaks its ticker before Go 1.23
What it finds
for range time.Tick(time.Second) in a function that returns: before Go 1.23 the ticker behind time.Tick is never stopped and never collected, so every call leaks a ticker that keeps firing. time.NewTicker with a deferred Stop releases it. Since Go 1.23 unreferenced tickers are collected.
The rule applies to files whose nearest go.mod names a version before 1.23. Reported are calls of time.Tick, resolved through the imports, inside functions other than main and init, which run once for the life of the program.
From the rule's source, tick_leak.rs.
Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:tick-leak" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:tick-leak] reason="..."tx0 explain tx0/go:tick-leak shows the same in the terminal. Found a false positive? Report it.