1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
package common import "os" // Exists returns whether the given file or directory exists or not func Exists(path string) bool { _, err := os.Stat(path) if err == nil { return true } if os.IsNotExist(err) { return false } return true }