Cleanup path logics with pathExists and binaryExists

This commit is contained in:
Filippo Valsorda
2019-06-01 14:55:58 +01:00
parent b1564cfb0d
commit 245b2732c8
5 changed files with 33 additions and 44 deletions

11
main.go
View File

@@ -14,6 +14,7 @@ import (
"net"
"net/mail"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
@@ -330,3 +331,13 @@ func fatalIfCmdErr(err error, cmd string, out []byte) {
log.Fatalf("ERROR: failed to execute \"%s\": %s\n\n%s\n", cmd, err, out)
}
}
func pathExists(path string) bool {
_, err := os.Stat(path)
return err == nil
}
func binaryExists(name string) bool {
_, err := exec.LookPath(name)
return err == nil
}