Handle import error rather than panic on failure

This should handle issue #9 more gracefully.
This commit is contained in:
Grant Murphy 2016-07-25 13:47:40 -07:00
parent 9ce14dc683
commit 2f84b67a47

View file

@ -83,7 +83,10 @@ func (gas *Analyzer) process(filename string, source interface{}) error {
conf := types.Config{Importer: importer.Default()} conf := types.Config{Importer: importer.Default()}
gas.context.Pkg, _ = conf.Check("pkg", gas.context.FileSet, []*ast.File{root}, gas.context.Info) gas.context.Pkg, _ = conf.Check("pkg", gas.context.FileSet, []*ast.File{root}, gas.context.Info)
// TODO: we need to look at the err ret if err != nil {
gas.logger.Println("failed to check imports")
return err
}
ast.Walk(gas, root) ast.Walk(gas, root)
gas.Stats.NumFiles++ gas.Stats.NumFiles++