Documentation ¶
Overview ¶
Package defers defines an Analyzer that checks for common mistakes in defer statements.
Analyzer defer ¶
defer: report common mistakes in defer statements
The defer 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: "defer", Requires: []*analysis.Analyzer{inspect.Analyzer}, Doc: analysisutil.MustExtractDoc(doc, "defer"), Run: run, }
Analyzer is the defer analyzer.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.