github.com/paketo-buildpacks/packit@v1.3.2-0.20211206231111-86b75c657449/fs/exists.go (about) 1 package fs 2 3 import ( 4 "errors" 5 "os" 6 ) 7 8 // Exists returns true if a file or directory at the given path is present and false otherwise. 9 func Exists(path string) (bool, error) { 10 _, err := os.Stat(path) 11 if err != nil { 12 if errors.Is(err, os.ErrNotExist) { 13 return false, nil 14 } 15 return false, err 16 } 17 return true, nil 18 }