From 007219f7b3f9f03d05c7ee6ef9e9eeec37ce12c2 Mon Sep 17 00:00:00 2001 From: Eray Ates Date: Fri, 26 Aug 2022 22:23:36 +0300 Subject: [PATCH] fix: funcDeclaration body check (#1310) Signed-off-by: Eray Ates --- packages.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages.go b/packages.go index 070d48d16..e7cf7a38b 100644 --- a/packages.go +++ b/packages.go @@ -164,7 +164,8 @@ func (pkgDefs *PackagesDefinitions) parseTypesFromFile(astFile *ast.File, packag func (pkgDefs *PackagesDefinitions) parseFunctionScopedTypesFromFile(astFile *ast.File, packagePath string, parsedSchemas map[*TypeSpecDef]*Schema) { for _, astDeclaration := range astFile.Decls { - if funcDeclaration, ok := astDeclaration.(*ast.FuncDecl); ok { + funcDeclaration, ok := astDeclaration.(*ast.FuncDecl) + if ok && funcDeclaration.Body != nil { for _, stmt := range funcDeclaration.Body.List { if declStmt, ok := (stmt).(*ast.DeclStmt); ok { if genDecl, ok := (declStmt.Decl).(*ast.GenDecl); ok && genDecl.Tok == token.TYPE {