From acd965b54e98b963351818a2afc705135ec32199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Henrique=20Guard=C3=A3o=20Gandarez?= Date: Tue, 26 Jan 2021 16:18:05 -0300 Subject: [PATCH] Add ini load options argument Signed-off-by: Mark Sagi-Kazar --- viper.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/viper.go b/viper.go index a89efe9..60f9868 100644 --- a/viper.go +++ b/viper.go @@ -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