mirror of
https://github.com/spf13/viper
synced 2025-05-06 20:27:17 +00:00
Fixed panic in AddConfigPath
This commit is contained in:
parent
f904a17905
commit
ce98f92b04
1 changed files with 5 additions and 1 deletions
4
util.go
4
util.go
|
@ -58,8 +58,12 @@ func absPathify(inPath string) string {
|
||||||
|
|
||||||
if strings.HasPrefix(inPath, "$") {
|
if strings.HasPrefix(inPath, "$") {
|
||||||
end := strings.Index(inPath, string(os.PathSeparator))
|
end := strings.Index(inPath, string(os.PathSeparator))
|
||||||
|
if end == -1 {
|
||||||
|
inPath = os.Getenv(inPath[1:])
|
||||||
|
} else {
|
||||||
inPath = os.Getenv(inPath[1:end]) + inPath[end:]
|
inPath = os.Getenv(inPath[1:end]) + inPath[end:]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if filepath.IsAbs(inPath) {
|
if filepath.IsAbs(inPath) {
|
||||||
return filepath.Clean(inPath)
|
return filepath.Clean(inPath)
|
||||||
|
|
Loading…
Add table
Reference in a new issue