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
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue