Skip to content

Commit

Permalink
feat: add symbols in regexp in order to being able take default value…
Browse files Browse the repository at this point in the history
…s that contains colon and comma symbols
  • Loading branch information
sergazyyev committed Sep 22, 2022
1 parent 12edf60 commit 4cebbf0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions load.go
Expand Up @@ -12,12 +12,12 @@ import (
"github.com/spf13/viper"
)

//Load load config into supported struct.
// Load load config into supported struct.
func (c *Config) Load(configStruct interface{}) error {
return c.loadInternal("", configStruct)
}

//Load load config with key into supported struct.
// Load load config with key into supported struct.
func (c *Config) LoadKey(key string, configStruct interface{}) error {
return c.loadInternal(key, configStruct)
}
Expand Down Expand Up @@ -82,7 +82,7 @@ func setTagName(hook string) viper.DecoderConfigOption {
}
}

//StringJSONArrayOrSlicesToConfig will convert Json Encoded Strings to Maps or Slices, Used Primarily to support Slices and Maps in Environment variables
// StringJSONArrayOrSlicesToConfig will convert Json Encoded Strings to Maps or Slices, Used Primarily to support Slices and Maps in Environment variables
func stringJSONArrayToSlice() func(f reflect.Kind, t reflect.Kind, data interface{}) (interface{}, error) {
return func(
f reflect.Kind,
Expand Down Expand Up @@ -168,7 +168,7 @@ func stringJSONObjToStruct() func(f reflect.Kind, t reflect.Kind, data interface
}

func expandEnvVariablesWithDefaults() func(f reflect.Kind, t reflect.Kind, data interface{}) (interface{}, error) {
var configWithEnvExpand = regexp.MustCompile(`(\${([\w@.]+)(\|([\w@.]+)?)?})`)
var configWithEnvExpand = regexp.MustCompile(`(\${([\w@.]+)(\|([\w@.:,]+)?)?})`)
var exactMatchEnvExpand = regexp.MustCompile(`^` + configWithEnvExpand.String() + `$`)
return func(
f reflect.Kind,
Expand Down

0 comments on commit 4cebbf0

Please sign in to comment.