GoPLS Viewer

Home|gopls/go/analysis/passes/lostcancel/testdata/src/b/b.go
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
5package main
6
7import "context"
8
9// Return from main is handled specially.
10// Since the program exits, there's no need to call cancel.
11func main() {
12    _cancel := context.WithCancel(nil)
13    if maybe {
14        cancel()
15    }
16}
17
18func 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
26var maybe bool
27
MembersX
main._
main.cancel
notMain
notMain._
notMain.cancel
maybe
context
main
Members
X