diff --git a/README.md b/README.md index 64bf474..8499efe 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,14 @@ viper.SetDefault("LayoutDir", "layouts") viper.SetDefault("Taxonomies", map[string]string{"tag": "tags", "category": "categories"}) ``` +Optionally you can get all Defaults values for config. + +example: + +```go +viper.GetDefaults() +``` + ### Reading Config Files Viper requires minimal configuration so it knows where to look for config files. diff --git a/viper.go b/viper.go index 963861a..eb2b91f 100644 --- a/viper.go +++ b/viper.go @@ -1087,6 +1087,12 @@ func (v *Viper) SetDefault(key string, value interface{}) { deepestMap[lastKey] = value } +// GetDefaults gets the all defaults values +func GetDefaults() map[string]interface{} { return v.GetDefaults() } +func (v *Viper) GetDefaults() map[string]interface{} { + return v.defaults +} + // Set sets the value for the key in the override regiser. // Set is case-insensitive for a key. // Will be used instead of values obtained via