about summary refs log tree commit diff
path: root/gopkgs
diff options
context:
space:
mode:
Diffstat (limited to 'gopkgs')
-rw-r--r--gopkgs/utils/utils.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/gopkgs/utils/utils.go b/gopkgs/utils/utils.go
index 7ac9defa6f0f..24121ed44c75 100644
--- a/gopkgs/utils/utils.go
+++ b/gopkgs/utils/utils.go
@@ -7,6 +7,7 @@ import (
 	"log"
 	"net/http"
 	"net/http/httputil"
+	"os"
 	"os/user"
 )
 
@@ -19,6 +20,15 @@ func HomeDir() string {
 	return user.HomeDir
 }
 
+// Return true if `path` exists and false otherwise.
+func FileExists(path string) bool {
+	if _, err := os.Stat(path); os.IsNotExist(err) {
+		return false
+	} else {
+		return true
+	}
+}
+
 // Call log.Fatal with `err` when it's not nil.
 func FailOn(err error) {
 	if err != nil {