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) }