Help us shape the future of Go! Take the 2026 Go Developer Survey

deferinloop

package
v0.87.8 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 8 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 = analyzerutil.New("deferinloop", "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", 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