Skip to content

Commit

Permalink
Add ini load options argument
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
  • Loading branch information
gandarez authored and sagikazarmark committed Jun 15, 2021
1 parent 5f4d053 commit acd965b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit acd965b

Please sign in to comment.