FindDefaultConfigPath returns the first path that contains a config file. If none of the combination of DefaultConfigSearchDirectories() and DefaultConfigFiles contains a config file, return empty string.
()
| 103 | // If none of the combination of DefaultConfigSearchDirectories() and DefaultConfigFiles |
| 104 | // contains a config file, return empty string. |
| 105 | func FindDefaultConfigPath() string { |
| 106 | for _, configDir := range DefaultConfigSearchDirectories() { |
| 107 | for _, configFile := range DefaultConfigFiles { |
| 108 | dirPath, err := homedir.Expand(configDir) |
| 109 | if err != nil { |
| 110 | continue |
| 111 | } |
| 112 | path := filepath.Join(dirPath, configFile) |
| 113 | if ok, _ := FileExists(path); ok { |
| 114 | return path |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | return "" |
| 119 | } |
| 120 | |
| 121 | // FindOrCreateConfigPath returns the first path that contains a config file |
| 122 | // or creates one in the primary default path if it doesn't exist |
no test coverage detected