File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package env
22
33import (
44 "encoding/base64"
5+ "encoding/json"
56 "errors"
67 "fmt"
78 "net/http"
@@ -2053,3 +2054,26 @@ func TestIssue234(t *testing.T) {
20532054 isEqual (t , "kek" , cfg .Foo .Str )
20542055 isEqual (t , "lel" , cfg .Bar .Str )
20552056}
2057+
2058+ type Issue308 struct {
2059+ Inner Issue308Map `env:"A_MAP"`
2060+ }
2061+
2062+ type Issue308Map map [string ][]string
2063+
2064+ func (rc * Issue308Map ) UnmarshalText (b []byte ) error {
2065+ m := map [string ][]string {}
2066+ if err := json .Unmarshal (b , & m ); err != nil {
2067+ return err
2068+ }
2069+ * rc = Issue308Map (m )
2070+ return nil
2071+ }
2072+
2073+ func TestIssue308 (t * testing.T ) {
2074+ t .Setenv ("A_MAP" , `{"FOO":["BAR", "ZAZ"]}` )
2075+
2076+ cfg := Issue308 {}
2077+ isNoErr (t , Parse (& cfg ))
2078+ isEqual (t , Issue308Map {"FOO" : []string {"BAR" , "ZAZ" }}, cfg .Inner )
2079+ }
You can’t perform that action at this time.
0 commit comments