2019-11-02 14:32:58 +00:00
|
|
|
package utils
|
2019-10-29 20:54:47 +00:00
|
|
|
|
2019-11-02 14:32:58 +00:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
)
|
2019-10-29 20:54:47 +00:00
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// FileExists returns whether the given file or directory exists.
|
2019-10-29 20:54:47 +00:00
|
|
|
func FileExists(path string) (bool, error) {
|
|
|
|
_, err := os.Stat(path)
|
|
|
|
if err == nil {
|
|
|
|
return true, nil
|
|
|
|
}
|
2020-05-05 19:35:32 +00:00
|
|
|
|
2019-10-29 20:54:47 +00:00
|
|
|
if os.IsNotExist(err) {
|
|
|
|
return false, nil
|
|
|
|
}
|
2020-05-05 19:35:32 +00:00
|
|
|
|
2019-10-29 20:54:47 +00:00
|
|
|
return true, err
|
|
|
|
}
|