Skip to content

Commit

Permalink
improve gfile.MainPkgPath
Browse files Browse the repository at this point in the history
  • Loading branch information
jianchenma committed Mar 19, 2021
1 parent 2f3df76 commit 4aaf09f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions os/gfile/gfile_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func MainPkgPath() string {
continue
}
}
if gregex.IsMatchString(`package\s+main`, GetContents(file)) {
if gregex.IsMatchString(`package\s+main\s+{`, GetContents(file)) {
mainPkgPath.Set(Dir(file))
return Dir(file)
}
Expand All @@ -79,7 +79,7 @@ func MainPkgPath() string {
for path = Dir(lastFile); 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)) {
if gregex.IsMatchString(`package\s+main\s+{`, GetContents(v)) {
mainPkgPath.Set(path)
return path
}
Expand Down

0 comments on commit 4aaf09f

Please sign in to comment.