Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
util/common: add PathExists helper
Browse files Browse the repository at this point in the history
Just basic helper function that's handy to have around. Not used yet.
  • Loading branch information
jlebon committed Jan 22, 2020
1 parent 2493f79 commit 48d1aa6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions util/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package util

import (
"os"
"unsafe"
)

Expand Down Expand Up @@ -50,3 +51,14 @@ func StrToPtr(s string) *string {
func BoolToPtr(b bool) *bool {
return &b
}

func PathExists(path string) (bool, error) {
_, err := os.Stat(path)
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
return true, nil
}

0 comments on commit 48d1aa6

Please sign in to comment.