mirror of
https://github.com/spf13/viper
synced 2024-12-22 19:47:01 +00:00
Add ini load options argument
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
parent
5f4d053c3e
commit
acd965b54e
1 changed files with 11 additions and 1 deletions
12
viper.go
12
viper.go
|
@ -199,6 +199,9 @@ type Viper struct {
|
||||||
configPermissions os.FileMode
|
configPermissions os.FileMode
|
||||||
envPrefix string
|
envPrefix string
|
||||||
|
|
||||||
|
// Specific commands for ini parsing
|
||||||
|
iniLoadOptions ini.LoadOptions
|
||||||
|
|
||||||
automaticEnvApplied bool
|
automaticEnvApplied bool
|
||||||
envKeyReplacer StringReplacer
|
envKeyReplacer StringReplacer
|
||||||
allowEmptyEnv bool
|
allowEmptyEnv bool
|
||||||
|
@ -1637,7 +1640,7 @@ func (v *Viper) unmarshalReader(in io.Reader, c map[string]interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
case "ini":
|
case "ini":
|
||||||
cfg := ini.Empty()
|
cfg := ini.Empty(v.iniLoadOptions)
|
||||||
err := cfg.Append(buf.Bytes())
|
err := cfg.Append(buf.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ConfigParseError{err}
|
return ConfigParseError{err}
|
||||||
|
@ -2081,6 +2084,13 @@ func (v *Viper) SetConfigPermissions(perm os.FileMode) {
|
||||||
v.configPermissions = perm.Perm()
|
v.configPermissions = perm.Perm()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IniLoadOptions sets the load options for ini parsing.
|
||||||
|
func IniLoadOptions(in ini.LoadOptions) Option {
|
||||||
|
return optionFunc(func(v *Viper) {
|
||||||
|
v.iniLoadOptions = in
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (v *Viper) getConfigType() string {
|
func (v *Viper) getConfigType() string {
|
||||||
if v.configType != "" {
|
if v.configType != "" {
|
||||||
return v.configType
|
return v.configType
|
||||||
|
|
Loading…
Reference in a new issue