github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/golint/testdata/unexp-return.go (about)

     1  // Test for unexported return types.
     2  
     3  // Package foo ...
     4  package foo
     5  
     6  import ()
     7  
     8  type hidden struct{}
     9  
    10  // Exported returns a hidden type, which is annoying.
    11  func Exported() hidden { // MATCH /Exported.*unexported.*hidden/
    12  	return hidden{}
    13  }
    14  
    15  // ExpErr returns a builtin type.
    16  func ExpErr() error { // ok
    17  }
    18  
    19  func (hidden) ExpOnHidden() hidden { // ok
    20  }
    21  
    22  // T is another test type.
    23  type T struct{}
    24  
    25  // MethodOnT returns a hidden type, which is annoying.
    26  func (T) MethodOnT() hidden { // MATCH /method MethodOnT.*unexported.*hidden/
    27  	return hidden{}
    28  }
    29  
    30  // ExpT returns a T.
    31  func ExpT() T { // ok
    32  	return T{}
    33  }
    34  
    35  func unexp() hidden { // ok
    36  	return hidden{}
    37  }
    38  
    39  // This is slightly sneaky: we shadow the builtin "int" type.
    40  
    41  type int struct{}
    42  
    43  // ExportedIntReturner returns an unexported type from this package.
    44  func ExportedIntReturner() int { // MATCH /ExportedIntReturner.*unexported.*int/
    45  	return int{}
    46  }