range
What it does
Section titled “What it does”for k, _ := range x: the second value is the blank identifier, so for k := range x says the same.
Why it matters
Section titled “Why it matters”for k, _ := range x and for k := range x do the same; the blank identifier is noise that suggests the second value matters. The short form is what gofmt -s produces, so code that uses it needs no later cleanup.
Example
Section titled “Example”package a
func f(xs []int) { for i, _ := range xs { }... }... } for _, _ = range xs { }... }...Configuration
Section titled “Configuration”go: lint: rules: range: warn # off (default), warn, errorEnabled by the presets: go/revive.
Suppress one line with sudsy-disable-next-line range in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| revive | range |
full |