defers

package
v0.0.0-...-076a18f Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

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.

Directories

Path Synopsis
cmd
defers
The defers command runs the defers analyzer.
The defers command runs the defers analyzer.

Jump to

Keyboard shortcuts

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