compileFuncDecl extracts the function declaration from the given code.
(code string)
| 264 | |
| 265 | // compileFuncDecl extracts the function declaration from the given code. |
| 266 | func compileFuncDecl(code string) (*dst.FuncDecl, error) { |
| 267 | f, err := decorator.Parse(fmt.Sprintf(`package stub |
| 268 | |
| 269 | func stub() { |
| 270 | %s |
| 271 | }`, strings.TrimSpace(code))) |
| 272 | if err != nil { |
| 273 | return nil, err |
| 274 | } |
| 275 | if len(f.Decls) != 1 { |
| 276 | return nil, xerrors.Errorf("expected 1 decl, got %d", len(f.Decls)) |
| 277 | } |
| 278 | decl, ok := f.Decls[0].(*dst.FuncDecl) |
| 279 | if !ok { |
| 280 | return nil, xerrors.Errorf("expected func decl, got %T", f.Decls[0]) |
| 281 | } |
| 282 | return decl, nil |
| 283 | } |
| 284 | |
| 285 | type querierFunction struct { |
| 286 | // Name is the name of the function. Like "GetUserByID" |
no test coverage detected