fix package name
This commit is contained in:
20
root_dir.go
Normal file
20
root_dir.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package root_dir
|
||||
|
||||
import (
|
||||
"os"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func RootDir(projectDirName string) string {
|
||||
if projectDirName == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
projectName := regexp.MustCompile(`^(.*` + projectDirName + `)`)
|
||||
currentWorkDirectory, _ := os.Getwd()
|
||||
rootPath := projectName.Find([]byte(currentWorkDirectory))
|
||||
if len(rootPath) <= 0 {
|
||||
return ""
|
||||
}
|
||||
return string(rootPath)
|
||||
}
|
||||
Reference in New Issue
Block a user