Source file test/fixedbugs/issue23586.go

     1  // errorcheck
     2  
     3  // Copyright 2018 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // Test that we type-check deferred/go functions even
     8  // if they are not called (a common error). Specifically,
     9  // we don't want to see errors such as import or variable
    10  // declared and not used.
    11  
    12  package p
    13  
    14  import (
    15  	"fmt"
    16  	"math"
    17  )
    18  
    19  func f() {
    20  	var i int
    21  	defer func() { fmt.Println() } // ERROR "must be function call"
    22  	go func() { _ = math.Sin(0) }  // ERROR "must be function call"
    23  	go func() { _ = i}             // ERROR "must be function call"
    24  }
    25  

View as plain text