From 13eb1150a5d5c3c4d62607cd3c1d40ae288e4b32 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 10 Jun 2019 21:32:40 +0800 Subject: [PATCH] fix issue in gfile.MainPkgPath --- g/os/gfile/gfile.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/g/os/gfile/gfile.go b/g/os/gfile/gfile.go index e55e156f4..e658a869b 100644 --- a/g/os/gfile/gfile.go +++ b/g/os/gfile/gfile.go @@ -425,8 +425,7 @@ func MainPkgPath() string { continue } // separator of '/' will be converted to Separator. - path = Dir(file) - for path[len(path) - 1] != os.PathSeparator { + for path = Dir(file); len(path) > 1 && Exists(path) && path[len(path) - 1] != os.PathSeparator; { files, _ := ScanDir(path, "*.go") for _, v := range files { if gregex.IsMatchString(`package\s+main`, GetContents(v)) {