.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.1.1 / staticcheck / testdata / src / CheckLeakyTimeTick / CheckLeakyTimeTick.go
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.1.1/staticcheck/testdata/src/CheckLeakyTimeTick/CheckLeakyTimeTick.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.1.1/staticcheck/testdata/src/CheckLeakyTimeTick/CheckLeakyTimeTick.go
new file mode 100644 (file)
index 0000000..d385c2a
--- /dev/null
@@ -0,0 +1,59 @@
+package pkg
+
+import "time"
+
+func fn1() {
+       for range time.Tick(0) {
+               println("")
+       }
+}
+
+func fn2() {
+       for range time.Tick(0) { // want `leaks the underlying ticker`
+               println("")
+               if true {
+                       break
+               }
+       }
+}
+
+func fn3() {
+       for range time.Tick(0) { // want `leaks the underlying ticker`
+               println("")
+               if true {
+                       return
+               }
+       }
+}
+
+func fn4() {
+       go func() {
+               for range time.Tick(0) {
+                       println("")
+               }
+       }()
+}
+
+func fn5() {
+       if false {
+               panic("foo")
+       }
+       for range time.Tick(0) {
+               println("")
+       }
+}
+
+
+type T struct{}
+
+func (t *T) foo() {
+       for range time.Tick(0) {
+               println("")
+       }
+}
+
+func (t T) bar() {
+       for range time.Tick(0) {
+               println("")
+       }
+}