Skip to content

Commit

Permalink
Handle pointer receivers
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph7C2 committed Jul 3, 2020
1 parent ca3e155 commit 0fc4c1b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/linter/linter.go
Expand Up @@ -58,7 +58,13 @@ func (l *linter) Lint(fileName string) {
func (l linter) handleFunctionDefinition(fd *ast.FuncDecl) {
name := fd.Name.Name
if fd.Recv != nil {
name = fmt.Sprintf("%s.%s", fd.Recv.List[0].Type, name)
expr := fd.Recv.List[0].Type
if starExpr, ok := expr.(*ast.StarExpr); ok {
expr = starExpr.X
}
if ident, ok := expr.(*ast.Ident); ok {
name = fmt.Sprintf("%s.%s", ident.Name, name)
}
}
l.handleFunction(name, fd.Pos(), fd.Type.Params.Closing, nil)
}
Expand Down

0 comments on commit 0fc4c1b

Please sign in to comment.