Documentation ¶
Overview ¶
Package defers defines an Analyzer that checks for common mistakes in defer statements.
Analyzer defers ¶
defers: report common mistakes in defer statements
The defers analyzer reports a diagnostic when a defer statement would result in a non-deferred call to time.Since, as experience has shown that this is nearly always a mistake.
For example:
start := time.Now() ... defer recordLatency(time.Since(start)) // error: call to time.Since is not deferred
The correct code is:
defer func() { recordLatency(time.Since(start)) }()
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Analyzer = &analysis.Analyzer{ Name: "defers", Requires: []*analysis.Analyzer{inspect.Analyzer}, URL: "https://pkg.go.dev/github.com/TBD54566975/golang-tools/go/analysis/passes/defers", Doc: analysisutil.MustExtractDoc(doc, "defers"), Run: run, }
Analyzer is the defers analyzer.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.