github.com/Johnny2210/revive@v1.0.8-0.20210625134200-febf37ccd0f5/testdata/golint/receiver-naming.go (about)

     1  // Test for bad receiver names.
     2  
     3  // Package foo ...
     4  package foo
     5  
     6  type foo struct{}
     7  
     8  func (this foo) f1() { // MATCH /receiver name should be a reflection of its identity; don't use generic names such as "this" or "self"/
     9  }
    10  
    11  func (self foo) f2() { // MATCH /receiver name should be a reflection of its identity; don't use generic names such as "this" or "self"/
    12  }
    13  
    14  func (f foo) f3() {
    15  }
    16  
    17  func (foo) f4() {
    18  }
    19  
    20  type bar struct{}
    21  
    22  func (b bar) f1() {
    23  }
    24  
    25  func (b bar) f2() {
    26  }
    27  
    28  func (a bar) f3() { // MATCH /receiver name a should be consistent with previous receiver name b for bar/
    29  }
    30  
    31  func (a *bar) f4() { // MATCH /receiver name a should be consistent with previous receiver name b for bar/
    32  }
    33  
    34  func (b *bar) f5() {
    35  }
    36  
    37  func (bar) f6() {
    38  }
    39  
    40  func (_ *bar) f7() { // MATCH /receiver name should not be an underscore, omit the name if it is unused/
    41  }
    42  
    43  type multiError struct{}
    44  
    45  func (me multiError) f8() {
    46  }
    47  
    48  // Regression test for a panic caused by ill-formed receiver type.
    49  func (recv []*x.y) f()