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

Method searchInPath

file.go:75–92  ·  view source on GitHub ↗
(in string)

Source from the content-addressed store, hash-verified

73}
74
75func (v *Viper) searchInPath(in string) (filename string) {
76 v.logger.Debug("searching for config in path", "path", in)
77 for _, ext := range SupportedExts {
78 v.logger.Debug("checking if file exists", "file", filepath.Join(in, v.configName+"."+ext))
79 if b, _ := exists(v.fs, filepath.Join(in, v.configName+"."+ext)); b {
80 v.logger.Debug("found file", "file", filepath.Join(in, v.configName+"."+ext))
81 return filepath.Join(in, v.configName+"."+ext)
82 }
83 }
84
85 if v.configType != "" {
86 if b, _ := exists(v.fs, filepath.Join(in, v.configName)); b {
87 return filepath.Join(in, v.configName)
88 }
89 }
90
91 return ""
92}
93
94// exists checks if file exists.
95func exists(fs afero.Fs, path string) (bool, error) {

Callers 1

findConfigFileOldMethod · 0.95

Calls 2

existsFunction · 0.85
DebugMethod · 0.80

Tested by

no test coverage detected