github.com/songshiyun/revive@v1.1.5-0.20220323112655-f8433a19b3c5/testdata/unused-receiver.go (about) 1 package fixtures 2 3 import ( 4 "fmt" 5 6 "github.com/songshiyun/revive/lint" 7 ) 8 9 func (f *Unix) Name() string { // MATCH /method receiver 'f' is not referenced in method's body, consider removing or renaming it as _/ 10 return "unix" 11 } 12 13 func (f *Unix) Format(failures <-chan lint.Failure, _ lint.RulesConfig) (string, error) { // MATCH /method receiver 'f' is not referenced in method's body, consider removing or renaming it as _/ 14 for failure := range failures { 15 fmt.Printf("%v: [%s] %s\n", failure.Position.Start, failure.RuleName, failure.Failure) 16 } 17 return "", nil 18 } 19 20 func (u *Unix) Foo() (string, error) { // MATCH /method receiver 'u' is not referenced in method's body, consider removing or renaming it as _/ 21 for failure := range failures { 22 u := 1 // shadowing the receiver 23 fmt.Printf("%v\n", u) 24 } 25 return "", nil 26 } 27 28 func (u *Unix) Foos() (string, error) { 29 for failure := range failures { 30 u := 1 // shadowing the receiver 31 fmt.Printf("%v\n", u) 32 } 33 34 return u, nil // use of the receiver 35 } 36 37 func (u *Unix) Bar() (string, error) { 38 for failure := range failures { 39 u.path = nil // modifies the receiver 40 fmt.Printf("%v\n", u) 41 } 42 return "", nil 43 }