| 44 | } |
| 45 | |
| 46 | func (v *Viper) findConfigFileWithFinder(finder Finder) (string, error) { |
| 47 | results, err := finder.Find(v.fs) |
| 48 | if err != nil { |
| 49 | return "", err |
| 50 | } |
| 51 | |
| 52 | if len(results) == 0 { |
| 53 | return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)} |
| 54 | } |
| 55 | |
| 56 | // We call clean on the final result to ensure that the path is in its canonical form. |
| 57 | // This is mostly for consistent path handling and to make sure tests pass. |
| 58 | return results[0], nil |
| 59 | } |
| 60 | |
| 61 | // Search all configPaths for any config file. |
| 62 | // Returns the first path that exists (and is a config file). |