mirror of
https://github.com/spf13/viper
synced 2024-12-23 03:57:01 +00:00
Added a straight forward merge of the maps of configuration objects.
This commit is contained in:
parent
7d1565ac32
commit
ea0dc3e3e0
1 changed files with 12 additions and 0 deletions
12
viper.go
12
viper.go
|
@ -950,6 +950,18 @@ func (v *Viper) MergeConfig(in io.Reader) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Merge a configuration into another.
|
||||
func Merge( other *Viper ) { v.Merge( other ) }
|
||||
func (v *Viper) Merge( other *Viper ) {
|
||||
mergeMaps( other.config, v.config, nil )
|
||||
mergeMaps( other.override, v.override, nil )
|
||||
mergeMaps( other.defaults, v.defaults, nil )
|
||||
mergeMaps( other.kvstore, v.kvstore, nil )
|
||||
for key,val := range other.pflags { v.pflags[key] = val }
|
||||
for key,val := range other.env { v.env[key] = val }
|
||||
for key,val := range other.aliases { v.aliases[key] = val }
|
||||
}
|
||||
|
||||
func keyExists(k string, m map[string]interface{}) string {
|
||||
lk := strings.ToLower(k)
|
||||
for mk := range m {
|
||||
|
|
Loading…
Reference in a new issue