From 4cc93d7d71715770521b555ebea4932099a8de7d Mon Sep 17 00:00:00 2001 From: visualfc Date: Sun, 26 Nov 2023 13:16:08 +0800 Subject: [PATCH] LoadDir: check mod valid --- load.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/load.go b/load.go index 3e8ae230b..e60631261 100644 --- a/load.go +++ b/load.go @@ -187,13 +187,16 @@ func LoadDir(dir string, conf *Config, genTestPkg bool, promptGenGo ...bool) (ou var pkgTest *ast.Package var clConf = &cl.Config{ - WorkingDir: dir, - Fset: fset, - Importer: imp, - LookupClass: mod.LookupClass, - LookupPub: c2go.LookupPub(mod), - FileLineRoot: mod.Root(), + WorkingDir: dir, + Fset: fset, + Importer: imp, + LookupClass: mod.LookupClass, + LookupPub: c2go.LookupPub(mod), } + if mod.IsValid() { + clConf.FileLineRoot = mod.Root() + } + for name, pkg := range pkgs { if strings.HasSuffix(name, "_test") { if pkgTest != nil {