forked from mirror/viper
Add ini load options argument
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
parent
5f4d053c3e
commit
acd965b54e
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 New Issue