added a check to parser to not panic

This commit is contained in:
David V. Wallin 2015-09-10 11:35:57 +02:00
parent a89f14d80d
commit f6d4629103
1 changed files with 4 additions and 1 deletions

View File

@ -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)
}
}
}
}