(recv *ast.FieldList)
| 594 | } |
| 595 | |
| 596 | func strip_method_receiver(recv *ast.FieldList) string { |
| 597 | var sel *ast.SelectorExpr |
| 598 | |
| 599 | // find selector expression |
| 600 | typ := recv.List[0].Type |
| 601 | switch t := typ.(type) { |
| 602 | case *ast.StarExpr: |
| 603 | sel, _ = t.X.(*ast.SelectorExpr) |
| 604 | case *ast.SelectorExpr: |
| 605 | sel = t |
| 606 | } |
| 607 | |
| 608 | // extract package path |
| 609 | if sel != nil { |
| 610 | pkg := sel.X.(*ast.Ident).Name |
| 611 | |
| 612 | // write back stripped type |
| 613 | switch typ.(type) { |
| 614 | case *ast.StarExpr: |
| 615 | *recv = ast.FieldList{ |
| 616 | List: []*ast.Field{{Names: recv.List[0].Names, Type: &ast.StarExpr{X: sel.Sel}}}, |
| 617 | } |
| 618 | case *ast.SelectorExpr: |
| 619 | *recv = ast.FieldList{ |
| 620 | List: []*ast.Field{{Names: recv.List[0].Names, Type: sel.Sel}}, |
| 621 | } |
| 622 | } |
| 623 | return pkg |
| 624 | } else { |
| 625 | return "" |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | // MethodDecl = "func" Receiver Name Signature . |
| 630 | // Receiver = "(" ( identifier | "?" ) [ "*" ] ExportedName ")" [ FuncBody ] . |
no outgoing calls
no test coverage detected