From f6d46291036881a5a924d2532bff3df6aaca213e Mon Sep 17 00:00:00 2001 From: "David V. Wallin" Date: Thu, 10 Sep 2015 11:35:57 +0200 Subject: [PATCH] added a check to parser to not panic --- parser.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parser.go b/parser.go index cf8dee22..7d55ffe3 100644 --- a/parser.go +++ b/parser.go @@ -77,7 +77,10 @@ func parserPkg(pkgRealpath, pkgpath string) error { switch specDecl := d.(type) { case *ast.FuncDecl: if specDecl.Recv != nil { - parserComments(specDecl.Doc, specDecl.Name.String(), fmt.Sprint(specDecl.Recv.List[0].Type.(*ast.StarExpr).X), pkgpath) + exp, ok := specDecl.Recv.List[0].Type.(*ast.StarExpr) // Check that the type is correct first beforing throwing to parser + if ok { + parserComments(specDecl.Doc, specDecl.Name.String(), fmt.Sprint(exp.X), pkgpath) + } } } }