diff options
Diffstat (limited to 'unix.go')
| -rw-r--r-- | unix.go | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -4,9 +4,11 @@ package repostatus import ( "os" "os/exec" + "os/user" "strings" "regexp" "errors" + "path/filepath" "go.wit.com/log" ) @@ -147,3 +149,40 @@ func runCmd(path string, parts []string) (error, bool, string) { // Print the output return nil, true, tmp } + +// Set the path to the package +// Replace this with the actual path to the github.com/coredns/coredns directory +func getfiles(pathToPackage string) { + // List files in the directory + err := filepath.Walk(pathToPackage, nil) // compiles but crashes + if err == nil { + log.Warn("directory ok", pathToPackage) + } else { + log.Warn("directory wrong", pathToPackage) + } +} + +func IsDirectory(path string) bool { + info, err := os.Stat(path) + if err != nil { + return false + } + return info.IsDir() +} + + + +func VerifyLocalGoRepo(gorepo string) bool { + // Get current user + usr, err := user.Current() + if err != nil { + log.Error(err, "VerifyLocalGoRepo() thinks you should switch to Ultrix") + return false + } + + // Form the path to the home Git directory + gitDir := filepath.Join(usr.HomeDir, "go/src/", gorepo, ".git") + + log.Warn("go directory:", gitDir) + return IsDirectory(gitDir) +} |
