1 | // Copyright 2018 The Go Authors. All rights reserved. |
---|---|
2 | // Use of this source code is governed by a BSD-style |
3 | // license that can be found in the LICENSE file. |
4 | |
5 | package main |
6 | |
7 | import "context" |
8 | |
9 | // Return from main is handled specially. |
10 | // Since the program exits, there's no need to call cancel. |
11 | func main() { |
12 | _, cancel := context.WithCancel(nil) |
13 | if maybe { |
14 | cancel() |
15 | } |
16 | } |
17 | |
18 | func notMain() { |
19 | _, cancel := context.WithCancel(nil) // want "cancel function.*not used" |
20 | |
21 | if maybe { |
22 | cancel() |
23 | } |
24 | } // want "return statement.*reached without using the cancel" |
25 | |
26 | var maybe bool |
27 |