summaryrefslogtreecommitdiffstats
path: root/src/cmd/vet/testdata/lostcancel/lostcancel.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/vet/testdata/lostcancel/lostcancel.go')
-rw-r--r--src/cmd/vet/testdata/lostcancel/lostcancel.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/cmd/vet/testdata/lostcancel/lostcancel.go b/src/cmd/vet/testdata/lostcancel/lostcancel.go
new file mode 100644
index 0000000..1bbb22d
--- /dev/null
+++ b/src/cmd/vet/testdata/lostcancel/lostcancel.go
@@ -0,0 +1,14 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package lostcancel
+
+import "context"
+
+func _() {
+ var _, cancel = context.WithCancel(context.Background()) // ERROR "the cancel function is not used on all paths \(possible context leak\)"
+ if false {
+ _ = cancel
+ }
+} // ERROR "this return statement may be reached without using the cancel var defined on line 10"