fix issue in gfile.MainPkgPath

This commit is contained in:
John 2019-06-04 18:30:02 +08:00
parent 33b24eba01
commit 16d978dc58

View File

@ -426,7 +426,7 @@ func MainPkgPath() string {
} }
// separator of <file> '/' will be converted to Separator. // separator of <file> '/' will be converted to Separator.
path = Dir(file) path = Dir(file)
for path != "/" && gstr.Contains(path, Separator) { for path[len(path) - 1] != os.PathSeparator {
files, _ := ScanDir(path, "*.go") files, _ := ScanDir(path, "*.go")
for _, v := range files { for _, v := range files {
if gregex.IsMatchString(`package\s+main`, GetContents(v)) { if gregex.IsMatchString(`package\s+main`, GetContents(v)) {