FileExists checks to see if a file exist at the provided path.
(path string)
| 87 | |
| 88 | // FileExists checks to see if a file exist at the provided path. |
| 89 | func FileExists(path string) (bool, error) { |
| 90 | f, err := os.Open(path) |
| 91 | if err != nil { |
| 92 | if os.IsNotExist(err) { |
| 93 | // ignore missing files |
| 94 | return false, nil |
| 95 | } |
| 96 | return false, err |
| 97 | } |
| 98 | _ = f.Close() |
| 99 | return true, nil |
| 100 | } |
| 101 | |
| 102 | // FindDefaultConfigPath returns the first path that contains a config file. |
| 103 | // If none of the combination of DefaultConfigSearchDirectories() and DefaultConfigFiles |