From a225a08dbc07912558304121ecf367d866d4f687 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 21 Sep 2018 21:56:47 -0700 Subject: [PATCH] add exists --- src/utils/exists.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/utils/exists.go diff --git a/src/utils/exists.go b/src/utils/exists.go new file mode 100644 index 0000000..4f4c743 --- /dev/null +++ b/src/utils/exists.go @@ -0,0 +1,13 @@ +package utils + +import "os" + +// Exists reports whether the named file or directory exists. +func Exists(name string) bool { + if _, err := os.Stat(name); err != nil { + if os.IsNotExist(err) { + return false + } + } + return true +}