From ac960d47a98c2d0b2b676f747dda52f0b5a0276c Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Fri, 8 Nov 2019 11:05:03 -0800 Subject: [PATCH 1/2] pkger hangs fixes #19 --- parser/parser.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/parser/parser.go b/parser/parser.go index 5c82410..032fa5d 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -80,23 +80,22 @@ func ParseDir(abs string, mode parser.Mode) ([]*ParsedSource, error) { if !info.IsDir() { return nil, fmt.Errorf("%s is not a directory", abs) } - dir := filepath.Dir(abs) - her, err := here.Dir(dir) + her, err := here.Dir(abs) if err != nil { - return nil, err + return nil, fmt.Errorf("%w: here.Dir failed %s", err, abs) } - pt, err := her.Parse(strings.TrimPrefix(abs, dir)) + pt, err := her.Parse(strings.TrimPrefix(abs, filepath.Dir(abs))) if err != nil { - return nil, err + return nil, fmt.Errorf("%w: here.Parse failed %s", err, abs) } fset := token.NewFileSet() pkgs, err := parser.ParseDir(fset, abs, nil, 0) if err != nil { - return nil, err + return nil, fmt.Errorf("%w: ParseDir failed %s", err, abs) } var srcs []*ParsedSource From 632f1083431070d8a7995dad788fc873a9c1b84f Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Fri, 8 Nov 2019 11:07:33 -0800 Subject: [PATCH 2/2] ignore .C errors --- here/dir.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/here/dir.go b/here/dir.go index cbe7774..8d5fe47 100644 --- a/here/dir.go +++ b/here/dir.go @@ -35,7 +35,7 @@ func Dir(p string) (Info, error) { if err != nil { es := err.Error() - if !(strings.Contains(es, "cannot find module for path .") || strings.Contains(es, "no Go files")) { + if !(strings.Contains(es, "cannot find module for path .") || strings.Contains(es, "no Go files") || strings.Contains(es, "can't load package")) { return i, err }