Add ini load options argument

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
Carlos Henrique Guardão Gandarez 2021-01-26 16:18:05 -03:00 committed by Márk Sági-Kazár
parent 5f4d053c3e
commit acd965b54e

View file

@ -199,6 +199,9 @@ type Viper struct {
configPermissions os.FileMode
envPrefix string
// Specific commands for ini parsing
iniLoadOptions ini.LoadOptions
automaticEnvApplied bool
envKeyReplacer StringReplacer
allowEmptyEnv bool
@ -1637,7 +1640,7 @@ func (v *Viper) unmarshalReader(in io.Reader, c map[string]interface{}) error {
}
case "ini":
cfg := ini.Empty()
cfg := ini.Empty(v.iniLoadOptions)
err := cfg.Append(buf.Bytes())
if err != nil {
return ConfigParseError{err}
@ -2081,6 +2084,13 @@ func (v *Viper) SetConfigPermissions(perm os.FileMode) {
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 {
if v.configType != "" {
return v.configType