Added IsDir and more tests

This commit is contained in:
sm
2015-08-09 20:18:41 -07:00
parent d65b52fedb
commit ec32af71be
2 changed files with 61 additions and 4 deletions
+12 -3
View File
@@ -4,10 +4,19 @@ import "os"
// Exists returns if a file exists
func Exists(path string) bool {
if _, err := os.Stat(path); err != nil {
return false
} else if os.IsNotExist(err) {
if _, err := os.Stat(path); os.IsNotExist(err) {
return false
}
return true
}
func IsDir(path string) bool {
info, err := os.Stat(path)
if err != nil {
return false
}
if info.IsDir() {
return true
}
return false
}