deferinloop

package
v0.80.9 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package deferinloop implements a Go analysis linter that flags defer statements placed directly inside for or range loop bodies. A defer inside a loop does not execute at the end of each iteration — it runs when the enclosing function returns, which can cause resource leaks and unexpected cleanup ordering.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:     "deferinloop",
	Doc:      "reports defer statements enclosed anywhere within a for or range loop body; a function literal between a defer and an enclosing loop is treated as a new scope boundary, making the defer exempt; test files are not checked",
	URL:      "https://github.com/github/gh-aw/tree/main/pkg/linters/deferinloop",
	Requires: []*analysis.Analyzer{inspect.Analyzer},
	Run:      run,
}

Analyzer is the defer-in-loop analysis pass.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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