This reverts CL 148758 (commit
5e17ce22ece18571597ef9a214cdfcd461894e9c)
Reason for revert: breaks the build.
Change-Id: I6ed15b7b8f6b74d84edab9402ddf7ae87a0d0387
Reviewed-on: https://go-review.googlesource.com/c/148817
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Martà <mvdan@mvdan.cc>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
var sig *types.Signature
switch node := node.(type) {
case *ast.FuncDecl:
- if node.Name.Name == "main" && node.Recv == nil && f.file.Name.Name == "main" {
- // Returning from main.main terminates the process,
- // so there's no need to cancel contexts.
- return
- }
obj := f.pkg.defs[node.Name]
if obj == nil {
return // type error (e.g. duplicate function declaration)
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package main
+package testdata
import (
"context"
ctx, _ = context.WithDeadline() // ERROR "the cancel function returned by context.WithDeadline should be called, not discarded, to avoid a context leak"
}
-// Return from main is handled specially.
-// Since the program exits, there's no need to call cancel.
-func main() {
- var ctx, cancel = context.WithCancel()
-}
-
func _() {
ctx, cancel := context.WithCancel()
defer cancel() // ok