diff --git a/.gitignore b/.gitignore index 7353b67..fb79c98 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ build/ vendor/ *.code-workspace -*.iml \ No newline at end of file +*.iml diff --git a/check-versions.go b/check-versions.go index dd12bb1..c04ecf7 100644 --- a/check-versions.go +++ b/check-versions.go @@ -2,43 +2,25 @@ package main import ( "fmt" - "os" "os/exec" - "runtime" "strings" ) -func validateos() { - if runtime.GOOS == "windows" { - fmt.Println("Can't Execute this on a windows machine") - os.Exit(1) - } -} -func execute(cmdstr string) string { - - validateos() - - var cmdargs = strings.Split(cmdstr, " ") // string arrayified - var cmd = cmdargs[0] // command +func execute(cmdstr string) (string, error) { + cmdargs := strings.Split(cmdstr, " ") // string arrayified + cmd := cmdargs[0] // command cmdargs = append(cmdargs[:0], cmdargs[1:]...) // argument array sans cmd out, err := exec.Command(cmd, cmdargs...).CombinedOutput() - var output string - - if err != nil { - output = err.Error() - } else { - output = string(out[:]) - } - return output + return string(out[:]), err } func main() { - gitver := execute("git --version") + gitver, _ := execute("git --version") verno := strings.Split(gitver, " ")[2] fmt.Println(verno) - gcnf := execute("git config -l") + gcnf, _ := execute("git config -l") config := strings.Split(gcnf, "\n") for i, v := range config { @@ -51,7 +33,7 @@ func main() { fmt.Printf("%d: %s = '%s' \n", i, key, val) } - glog := execute("git log --oneline") + glog, _ := execute("git log --oneline") logarray := strings.Split(glog, "\n") for _, v := range logarray { entryarray := strings.SplitN(v, " ", 2)