Search all configPaths for any config file. Returns the first path that exists (and is a config file).
()
| 61 | // Search all configPaths for any config file. |
| 62 | // Returns the first path that exists (and is a config file). |
| 63 | func (v *Viper) findConfigFileOld() (string, error) { |
| 64 | v.logger.Info("searching for config in paths", "paths", v.configPaths) |
| 65 | |
| 66 | for _, cp := range v.configPaths { |
| 67 | file := v.searchInPath(cp) |
| 68 | if file != "" { |
| 69 | return file, nil |
| 70 | } |
| 71 | } |
| 72 | return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)} |
| 73 | } |
| 74 | |
| 75 | func (v *Viper) searchInPath(in string) (filename string) { |
| 76 | v.logger.Debug("searching for config in path", "path", in) |
no test coverage detected