Repository: caarlos0/env (go)

Issue:
[bug] []byte conversion
@caarlos0 I have a custom func for `[]bytes`, after this [PR](https://github.com/caarlos0/env/pull/223) I got the following error:
```bash
panic: env: parse error on field "Abc" of type "[]uint8": strconv.ParseUint: parsing "asdasd": invalid syntax
```
my mapping
```
Abc       []byte `env:"ABC" envDefault:"asdasd"`
```
my custom func
```go
func parseSliceOfBytes(c *Config) {
	if err := env.ParseWithFuncs(c, map[reflect.Type]env.ParserFunc{
		reflect.TypeOf([]byte{0}): func(v string) (interface{}, error) {
			return []byte(v), nil
		},
	}); err != nil {
		panic(err)
	}
}
```

Pull request description:
fix: custom parsers with anon inner structs
fixes #226 

it was not passing down the funcmap to the children anon structs, which was causing a weird error in this particular case.

Patch:
diff --git a/env.go b/env.go
index e9ea4c6..f5401d6 100644
--- a/env.go
+++ b/env.go
@@ -218,7 +218,7 @@ func doParse(ref reflect.Value, funcMap map[reflect.Type]ParserFunc, opts []Opti
 			continue
 		}
 		if reflect.Struct == refField.Kind() && refField.CanAddr() && refField.Type().Name() == "" {
-			if err := Parse(refField.Addr().Interface(), optsWithPrefix(refType.Field(i), opts)...); err != nil {
+			if err := ParseWithFuncs(refField.Addr().Interface(), funcMap, optsWithPrefix(refType.Field(i), opts)...); err != nil {
 				return err
 			}
 			continue


Test patch:
diff --git a/env_test.go b/env_test.go
index 23a105f..7b33059 100644
--- a/env_test.go
+++ b/env_test.go
@@ -799,6 +799,34 @@ func TestCustomParser(t *testing.T) {
 	}
 }
 
+func TestIssue226(t *testing.T) {
+	type config struct {
+		Inner struct {
+			Abc []byte `env:"ABC" envDefault:"asdasd"`
+			Def []byte `env:"DEF" envDefault:"a"`
+		}
+		Hij []byte `env:"HIJ"`
+		Lmn []byte `env:"LMN"`
+	}
+
+	setEnv(t, "HIJ", "a")
+	setEnv(t, "LMN", "b")
+
+	cfg := &config{}
+	isNoErr(t, ParseWithFuncs(cfg, map[reflect.Type]ParserFunc{
+		reflect.TypeOf([]byte{0}): func(v string) (interface{}, error) {
+			if v == "a" {
+				return []byte("nope"), nil
+			}
+			return []byte(v), nil
+		},
+	}))
+	isEqual(t, cfg.Inner.Abc, []byte("asdasd"))
+	isEqual(t, cfg.Inner.Def, []byte("nope"))
+	isEqual(t, cfg.Hij, []byte("nope"))
+	isEqual(t, cfg.Lmn, []byte("b"))
+}
+
 func TestParseWithFuncsNoPtr(t *testing.T) {
 	type foo struct{}
 	isErrorWithMessage(t, ParseWithFuncs(foo{}, nil), "env: expected a pointer to a Struct")