mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 12:17:53 +08:00
improve gfile.MainPkgPath
This commit is contained in:
parent
2f3df76f37
commit
4aaf09fded
@ -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)
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user