add map support

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-12-04 22:41:46 +03:00
parent 19fefe591c
commit 2868c39a87
2 changed files with 25 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ type Config struct {
BoolValue bool `env:"BOOL_VALUE"`
StringSlice []string `env:"STRING_SLICE"`
IntSlice []int `env:"INT_SLICE"`
MapStringValue map[string]string `env:"MAP_STRING"`
}
func TestEnv(t *testing.T) {
@@ -38,6 +39,7 @@ func TestEnv(t *testing.T) {
os.Setenv("BOOL_VALUE","true")
os.Setenv("STRING_SLICE", "STRING_SLICE1,STRING_SLICE2;STRING_SLICE3")
os.Setenv("INT_SLICE", "1,2,3,4,5")
os.Setenv("MAP_STRING", "key1=val1,key2=val2")
if err := cfg.Load(ctx); err !=nil {
t.Fatal(err)