pkg/utils: Add function to conveniently check if a path exists

https://github.com/containers/toolbox/pull/318
This commit is contained in:
Harry Míchal 2020-04-29 16:03:50 +02:00 committed by Debarshi Ray
parent 7ab4ca868c
commit bd5b8065ae
1 changed files with 9 additions and 0 deletions

View File

@ -22,6 +22,15 @@ import (
"syscall" "syscall"
) )
// PathExists wraps around os.Stat providing a nice interface for checking an existence of a path.
func PathExists(path string) bool {
if _, err := os.Stat(path); !os.IsNotExist(err) {
return true
}
return false
}
func ShowManual(manual string) error { func ShowManual(manual string) error {
manBinary, err := exec.LookPath("man") manBinary, err := exec.LookPath("man")
if err != nil { if err != nil {