github.com/golangci/go-tools@v0.0.0-20190318060251-af6baa5dc196/staticcheck/testdata/src/CheckDeferInInfiniteLoop/CheckDeferInInfiniteLoop.go (about) 1 package pkg 2 3 func fn() { 4 for { 5 defer println() // MATCH /will never run/ 6 } 7 for { 8 defer println() // MATCH /will never run/ 9 go func() { 10 return 11 }() 12 } 13 for { 14 defer println() 15 return 16 } 17 for false { 18 defer println() 19 } 20 for { 21 defer println() 22 break 23 } 24 for { 25 defer println() 26 if true { 27 break 28 } 29 } 30 for { 31 defer println() 32 // Right now, we treat every break the same. We could analyse 33 // this further and see, that the break doesn't break out of 34 // the outer loop. 35 for { 36 break 37 } 38 } 39 }