@@ -132,10 +132,10 @@ type DecoderConfigOption func(*mapstructure.DecoderConfig)
132
132
// DecodeHook returns a DecoderConfigOption which overrides the default
133
133
// DecoderConfig.DecodeHook value, the default is:
134
134
//
135
- // mapstructure.ComposeDecodeHookFunc(
136
- // mapstructure.StringToTimeDurationHookFunc(),
137
- // mapstructure.StringToSliceHookFunc(","),
138
- // )
135
+ // mapstructure.ComposeDecodeHookFunc(
136
+ // mapstructure.StringToTimeDurationHookFunc(),
137
+ // mapstructure.StringToSliceHookFunc(","),
138
+ // )
139
139
func DecodeHook (hook mapstructure.DecodeHookFunc ) DecoderConfigOption {
140
140
return func (c * mapstructure.DecoderConfig ) {
141
141
c .DecodeHook = hook
@@ -156,18 +156,18 @@ func DecodeHook(hook mapstructure.DecodeHookFunc) DecoderConfigOption {
156
156
//
157
157
// For example, if values from the following sources were loaded:
158
158
//
159
- // Defaults : {
160
- // "secret": "",
161
- // "user": "default",
162
- // "endpoint": "https://localhost"
163
- // }
164
- // Config : {
165
- // "user": "root"
166
- // "secret": "defaultsecret"
167
- // }
168
- // Env : {
169
- // "secret": "somesecretkey"
170
- // }
159
+ // Defaults : {
160
+ // "secret": "",
161
+ // "user": "default",
162
+ // "endpoint": "https://localhost"
163
+ // }
164
+ // Config : {
165
+ // "user": "root"
166
+ // "secret": "defaultsecret"
167
+ // }
168
+ // Env : {
169
+ // "secret": "somesecretkey"
170
+ // }
171
171
//
172
172
// The resulting config will have the following values:
173
173
//
@@ -785,7 +785,8 @@ func (v *Viper) searchMapWithPathPrefixes(
785
785
// isPathShadowedInDeepMap makes sure the given path is not shadowed somewhere
786
786
// on its path in the map.
787
787
// e.g., if "foo.bar" has a value in the given map, it “shadows”
788
- // "foo.bar.baz" in a lower-priority map
788
+ //
789
+ // "foo.bar.baz" in a lower-priority map
789
790
func (v * Viper ) isPathShadowedInDeepMap (path []string , m map [string ]interface {}) string {
790
791
var parentVal interface {}
791
792
for i := 1 ; i < len (path ); i ++ {
@@ -810,7 +811,8 @@ func (v *Viper) isPathShadowedInDeepMap(path []string, m map[string]interface{})
810
811
// isPathShadowedInFlatMap makes sure the given path is not shadowed somewhere
811
812
// in a sub-path of the map.
812
813
// e.g., if "foo.bar" has a value in the given map, it “shadows”
813
- // "foo.bar.baz" in a lower-priority map
814
+ //
815
+ // "foo.bar.baz" in a lower-priority map
814
816
func (v * Viper ) isPathShadowedInFlatMap (path []string , mi interface {}) string {
815
817
// unify input map
816
818
var m map [string ]interface {}
@@ -835,7 +837,8 @@ func (v *Viper) isPathShadowedInFlatMap(path []string, mi interface{}) string {
835
837
// isPathShadowedInAutoEnv makes sure the given path is not shadowed somewhere
836
838
// in the environment, when automatic env is on.
837
839
// e.g., if "foo.bar" has a value in the environment, it “shadows”
838
- // "foo.bar.baz" in a lower-priority map
840
+ //
841
+ // "foo.bar.baz" in a lower-priority map
839
842
func (v * Viper ) isPathShadowedInAutoEnv (path []string ) string {
840
843
var parentKey string
841
844
for i := 1 ; i < len (path ); i ++ {
@@ -856,11 +859,11 @@ func (v *Viper) isPathShadowedInAutoEnv(path []string) string {
856
859
// would return a string slice for the key if the key's type is inferred by
857
860
// the default value and the Get function would return:
858
861
//
859
- // []string {"a", "b", "c"}
862
+ // []string {"a", "b", "c"}
860
863
//
861
864
// Otherwise the Get function would return:
862
865
//
863
- // "a b c"
866
+ // "a b c"
864
867
func SetTypeByDefaultValue (enable bool ) { v .SetTypeByDefaultValue (enable ) }
865
868
866
869
func (v * Viper ) SetTypeByDefaultValue (enable bool ) {
@@ -1137,9 +1140,8 @@ func (v *Viper) BindPFlags(flags *pflag.FlagSet) error {
1137
1140
// BindPFlag binds a specific key to a pflag (as used by cobra).
1138
1141
// Example (where serverCmd is a Cobra instance):
1139
1142
//
1140
- // serverCmd.Flags().Int("port", 1138, "Port to run Application server on")
1141
- // Viper.BindPFlag("port", serverCmd.Flags().Lookup("port"))
1142
- //
1143
+ // serverCmd.Flags().Int("port", 1138, "Port to run Application server on")
1144
+ // Viper.BindPFlag("port", serverCmd.Flags().Lookup("port"))
1143
1145
func BindPFlag (key string , flag * pflag.Flag ) error { return v .BindPFlag (key , flag ) }
1144
1146
1145
1147
func (v * Viper ) BindPFlag (key string , flag * pflag.Flag ) error {
@@ -1972,9 +1974,10 @@ func (v *Viper) AllKeys() []string {
1972
1974
1973
1975
// flattenAndMergeMap recursively flattens the given map into a map[string]bool
1974
1976
// of key paths (used as a set, easier to manipulate than a []string):
1975
- // - each path is merged into a single key string, delimited with v.keyDelim
1976
- // - if a path is shadowed by an earlier value in the initial shadow map,
1977
- // it is skipped.
1977
+ // - each path is merged into a single key string, delimited with v.keyDelim
1978
+ // - if a path is shadowed by an earlier value in the initial shadow map,
1979
+ // it is skipped.
1980
+ //
1978
1981
// The resulting set of paths is merged to the given shadow set at the same time.
1979
1982
func (v * Viper ) flattenAndMergeMap (shadow map [string ]bool , m map [string ]interface {}, prefix string ) map [string ]bool {
1980
1983
if shadow != nil && prefix != "" && shadow [prefix ] {
0 commit comments