github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/staticcheck/testdata/CheckLeakyTimeTick.go (about) 1 package pkg 2 3 import "time" 4 5 func fn1() { 6 for range time.Tick(0) { 7 println("") 8 } 9 } 10 11 func fn2() { 12 for range time.Tick(0) { // MATCH /leaks the underlying ticker/ 13 println("") 14 if true { 15 break 16 } 17 } 18 } 19 20 func fn3() { 21 for range time.Tick(0) { // MATCH /leaks the underlying ticker/ 22 println("") 23 if true { 24 return 25 } 26 } 27 } 28 29 func fn4() { 30 go func() { 31 for range time.Tick(0) { 32 println("") 33 } 34 }() 35 } 36 37 type T struct{} 38 39 func (t *T) foo() { 40 for range time.Tick(0) { 41 println("") 42 } 43 } 44 45 func (t T) bar() { 46 for range time.Tick(0) { 47 println("") 48 } 49 }