MCPcopy
hub / github.com/spf13/viper / findConfigFile

Method findConfigFile

file.go:20–44  ·  view source on GitHub ↗

Search for a config file.

()

Source from the content-addressed store, hash-verified

18
19// Search for a config file.
20func (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
46func (v *Viper) findConfigFileWithFinder(finder Finder) (string, error) {
47 results, err := finder.Find(v.fs)

Callers 1

getConfigFileMethod · 0.95

Calls 2

findConfigFileOldMethod · 0.95

Tested by

no test coverage detected