viper_go1_16.go (662B)
1 //go:build go1.16 && finder 2 // +build go1.16,finder 3 4 package viper 5 6 import ( 7 "fmt" 8 9 "github.com/spf13/afero" 10 ) 11 12 // Search all configPaths for any config file. 13 // Returns the first path that exists (and is a config file). 14 func (v *Viper) findConfigFile() (string, error) { 15 finder := finder{ 16 paths: v.configPaths, 17 fileNames: []string{v.configName}, 18 extensions: SupportedExts, 19 withoutExtension: v.configType != "", 20 } 21 22 file, err := finder.Find(afero.NewIOFS(v.fs)) 23 if err != nil { 24 return "", err 25 } 26 27 if file == "" { 28 return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)} 29 } 30 31 return file, nil 32 }