Search for a config file.
()
| 18 | |
| 19 | // Search for a config file. |
| 20 | func (v *Viper) findConfigFile() (string, error) { |
| 21 | finder := v.finder |
| 22 | |
| 23 | if finder == nil && v.experimentalFinder { |
| 24 | var names []string |
| 25 | |
| 26 | if v.configType != "" { |
| 27 | names = locafero.NameWithOptionalExtensions(v.configName, SupportedExts...) |
| 28 | } else { |
| 29 | names = locafero.NameWithExtensions(v.configName, SupportedExts...) |
| 30 | } |
| 31 | |
| 32 | finder = locafero.Finder{ |
| 33 | Paths: v.configPaths, |
| 34 | Names: names, |
| 35 | Type: locafero.FileTypeFile, |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | if finder != nil { |
| 40 | return v.findConfigFileWithFinder(finder) |
| 41 | } |
| 42 | |
| 43 | return v.findConfigFileOld() |
| 44 | } |
| 45 | |
| 46 | func (v *Viper) findConfigFileWithFinder(finder Finder) (string, error) { |
| 47 | results, err := finder.Find(v.fs) |
no test coverage detected