github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/staticcheck/sa5002/testdata/src/example.com/CheckInfiniteEmptyLoop/CheckInfiniteEmptyLoop.go (about) 1 package pkg 2 3 func fn2() bool { return true } 4 5 func fn() { 6 for { //@ diag(`this loop will spin`) 7 } 8 9 for fn2() { 10 } 11 12 for { 13 break 14 } 15 16 for true { //@ diag(`loop condition never changes`), diag(`this loop will spin`) 17 } 18 19 x := true 20 for x { //@ diag(`loop condition never changes`), diag(`this loop will spin`) 21 } 22 23 x = false 24 for x { //@ diag(`loop condition never changes`), diag(`this loop will spin`) 25 } 26 27 for false { 28 } 29 30 false := true 31 for false { //@ diag(`loop condition never changes`), diag(`this loop will spin`) 32 } 33 }