mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-05 00:39:59 +00:00
67ac8db190
* Upstep Go dependencies * tiny linter fix * Tidy
33 lines
662 B
Go
33 lines
662 B
Go
//go:build go1.16 && finder
|
|
// +build go1.16,finder
|
|
|
|
package viper
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/afero"
|
|
)
|
|
|
|
// Search all configPaths for any config file.
|
|
// Returns the first path that exists (and is a config file).
|
|
func (v *Viper) findConfigFile() (string, error) {
|
|
finder := finder{
|
|
paths: v.configPaths,
|
|
fileNames: []string{v.configName},
|
|
extensions: SupportedExts,
|
|
withoutExtension: v.configType != "",
|
|
}
|
|
|
|
file, err := finder.Find(afero.NewIOFS(v.fs))
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
if file == "" {
|
|
return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)}
|
|
}
|
|
|
|
return file, nil
|
|
}
|