From 4cebbf0823dcc1260a4c42da733a535519797810 Mon Sep 17 00:00:00 2001 From: Nursultan Date: Thu, 22 Sep 2022 21:48:18 +0600 Subject: [PATCH] feat: add symbols in regexp in order to being able take default values that contains colon and comma symbols --- load.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/load.go b/load.go index a434dd7..df3d5e5 100644 --- a/load.go +++ b/load.go @@ -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) } @@ -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, @@ -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,