timeafter

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package timeafter provides an analysis.Analyzer that reports timer ceremony a channel receive can replace.

One check: a time.NewTimer whose only uses are at most a deferred Stop and a single <-timer.C receive in a select sharing the declaration's statement list can be replaced by time.After in the receive. Since Go 1.23 the collector reclaims unreferenced timers before they fire, so the historical leak that justified the ceremony is gone. Statements may run between the declaration and the select; moving the deadline into the receive starts it later, which is the author's call. A timer that is Stopped conditionally, Reset, or received elsewhere is a real timer and is left alone, as is a select nested deeper than the declaration — inside a loop, most commonly — where time.After would restart the deadline every iteration. Only the timer := time.NewTimer(d) form is examined.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "timeafter",
	Doc:  "reports timer ceremony that can be replaced by time.After",
	Run:  run,
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
timeafter command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL