github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/staticcheck/sa4004/testdata/src/example.com/CheckIneffectiveLoop/CheckIneffectiveLoop.go (about) 1 package pkg 2 3 func fn() { 4 for { 5 if true { 6 println() 7 } 8 break //@ diag(`the surrounding loop is unconditionally terminated`) 9 } 10 for { 11 if true { 12 break 13 } else { 14 break 15 } 16 } 17 for range ([]int)(nil) { 18 if true { 19 println() 20 } 21 break //@ diag(`the surrounding loop is unconditionally terminated`) 22 } 23 for range (map[int]int)(nil) { 24 if true { 25 println() 26 } 27 break 28 } 29 for { 30 if true { 31 goto Label 32 } 33 break 34 Label: 35 } 36 for { 37 if true { 38 continue 39 } 40 break 41 } 42 for { 43 if true { 44 continue 45 } 46 break 47 } 48 } 49 50 var z = func() { 51 for { 52 if true { 53 println() 54 } 55 break //@ diag(`the surrounding loop is unconditionally terminated`) 56 } 57 }