copyloopvar

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 6 Imported by: 1

README

copyloopvar

copyloopvar is a linter detects places where loop variables are copied.

cf. Fixing For Loops in Go 1.22

Example

for i, v := range []int{1, 2, 3} {
    i := i // The copy of the 'for' variable "i" can be deleted (Go 1.22+)
    v := v // The copy of the 'for' variable "v" can be deleted (Go 1.22+)
    _, _ = i, v
}

for i := 1; i <= 3; i++ {
    i := i // The copy of the 'for' variable "i" can be deleted (Go 1.22+)
    _ = i
}

Install

go install github.com/karamaru-alpha/copyloopvar/cmd/copyloopvar@latest
go vet -vettool=`which copyloopvar` ./...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAnalyzer added in v1.0.5

func NewAnalyzer() *analysis.Analyzer

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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