diff --git a/lang/golang/parser/ctx.go b/lang/golang/parser/ctx.go index 89bdb37..299cc0c 100644 --- a/lang/golang/parser/ctx.go +++ b/lang/golang/parser/ctx.go @@ -121,7 +121,7 @@ func (p *GoParser) getFileBytes(path string) []byte { } bs, err := os.ReadFile(path) if err != nil { - panic(err) + panic(fmt.Sprintf("read file %s failed: %v", path, err)) } p.files[path] = bs return bs diff --git a/lang/golang/parser/pkg.go b/lang/golang/parser/pkg.go index e044397..7481650 100644 --- a/lang/golang/parser/pkg.go +++ b/lang/golang/parser/pkg.go @@ -229,6 +229,10 @@ func (p *GoParser) loadPackages(mod *Module, dir string, pkgPath PkgPath) (err e filePath = pkg.CompiledGoFiles[idx] } else { filePath = fset.Position(file.Pos()).Filename + if filePath == "" { + fmt.Fprintf(os.Stderr, "filename is empty, pkg: %s\n", pkg.ID) + continue + } } var skip bool for _, exclude := range p.exclues {