Skip to content

range

Gostyleno fixdefault: offgo/revive

for k, _ := range x: the second value is the blank identifier, so for k := range x says the same.

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.

Reported
package a
func f(xs []int) {
for i, _ := range xs {
}
...
}
...
}
for _, _ = range xs {
}
...
}
...
go:
lint:
rules:
range: warn # off (default), warn, error

Enabled by the presets: go/revive.

Suppress one line with sudsy-disable-next-line range in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
revive range full