esimonov / ifshort

Go linter for checking that your code uses short syntax for if-statements whenever possible.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

False positive with label breaks

tobiasgiese opened this issue · comments

False positive using labeled breaks

package main

func main() {
	foo := true
BREAKOUT:
	for i := range []int{0, 1, 2} {
		for j := range []int{0, 1, 2} {
			if j == 2 && i == 2 {
				foo = false
				break BREAKOUT
			}
		}
	}
	if foo {
		return
	}
}
$ ifshort main.go
/tmp/main.go:4:2: variable 'foo' is only used in the if-statement (/tmp/main.go:14:2); consider using short syntax