From 86873b296cb856a1b8e7251047ccb2b04d188f9b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 13 Jan 2024 00:43:26 -0600 Subject: work Signed-off-by: Jeff Carr --- unix.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'unix.go') diff --git a/unix.go b/unix.go index 772e3b7..215a199 100644 --- a/unix.go +++ b/unix.go @@ -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) +} -- cgit v1.2.3