honnef.co/go/tools@v0.4.7/staticcheck/testdata/src/example.com/CheckRepeatedIfElse/CheckRepeatedIfElse.go (about) 1 package pkg 2 3 func fn1(b1, b2 bool) { 4 if b1 && !b2 { 5 } else if b1 { 6 } else if b1 && !b2 { //@ diag(`condition occurs multiple times`) 7 } else if b1 { //@ diag(`condition occurs multiple times`) 8 } else { 9 println() 10 } 11 } 12 13 func fn2(b1, b2 bool, ch chan string) { 14 if b1 && !b2 { 15 } else if b1 { 16 } else if <-ch == "" { 17 } else if <-ch == "" { 18 } else { 19 println() 20 } 21 } 22 23 func fn3() { 24 if gen() { 25 println() 26 } else if gen() { 27 println() 28 } 29 } 30 31 func fn4() { 32 if s := gen2(); s == "" { 33 } else if s := gen2(); s == "" { 34 println() 35 } 36 } 37 38 func fn5() { 39 var s string 40 if s = gen2(); s == "" { 41 } else if s != "foo" { 42 } else if s = gen2(); s == "" { 43 } else if s != "foo" { 44 println() 45 } 46 } 47 48 func fn6() { 49 if true { 50 } else { 51 } 52 } 53 54 func gen() bool { return false } 55 func gen2() string { return "" }