github.com/golangci/go-tools@v0.0.0-20190318060251-af6baa5dc196/unused/testdata/src/functions/functions.go (about)

     1  package main
     2  
     3  type state func() state
     4  
     5  func a() state {
     6  	return a
     7  }
     8  
     9  func main() {
    10  	st := a
    11  	_ = st()
    12  }
    13  
    14  type t1 struct{} // MATCH /t1 is unused/
    15  type t2 struct{}
    16  type t3 struct{}
    17  
    18  func fn1() t1     { return t1{} } // MATCH /fn1 is unused/
    19  func fn2() (x t2) { return }
    20  func fn3() *t3    { return nil }
    21  
    22  func fn4() {
    23  	const x = 1
    24  	const y = 2  // MATCH /y is unused/
    25  	type foo int // MATCH /foo is unused/
    26  	type bar int
    27  
    28  	_ = x
    29  	var _ bar
    30  }
    31  
    32  func init() {
    33  	fn2()
    34  	fn3()
    35  	fn4()
    36  }