fix merge

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-12-20 00:34:31 +03:00
parent ab6b82304a
commit afab7aa1d6

6
env.go
View File

@ -37,15 +37,15 @@ func (c *envConfig) Load(ctx context.Context) error {
} }
} }
dst, err := config.Zero(c.opts.Struct) src, err := config.Zero(c.opts.Struct)
if err == nil { if err == nil {
err = c.fillValues(ctx, reflect.ValueOf(dst)) err = c.fillValues(ctx, reflect.ValueOf(src))
} }
if err != nil && !c.opts.AllowFail { if err != nil && !c.opts.AllowFail {
return err return err
} }
if err = mergo.Merge(c.opts.Struct, dst, mergo.WithOverride, mergo.WithTypeCheck, mergo.WithAppendSlice); err != nil && !c.opts.AllowFail { if err = mergo.Merge(c.opts.Struct, src, mergo.WithOverride, mergo.WithTypeCheck, mergo.WithAppendSlice); err != nil && !c.opts.AllowFail {
return err return err
} }