diff --git a/inmem.go b/inmem.go index 14c46ca..a6f0dd1 100644 --- a/inmem.go +++ b/inmem.go @@ -430,14 +430,15 @@ func (w *pipeSender) copyStructure(m interface{}) (interface{}, error) { } func (w *pipeSender) copyStructValue(v reflect.Value) (interface{}, error) { - mCopy := make(map[string]interface{}) - t := v.Type() + mCopy := reflect.New(v.Type()).Elem() for i := 0; i < v.NumField(); i++ { vCopy, vErr := w.copyValue(v.Field(i).Interface()) if vErr != nil { return nil, vErr } - mCopy[t.Field(i).Name] = vCopy + if vCopy != nil { + mCopy.Field(i).Set(reflect.ValueOf(vCopy)) + } } - return mCopy, nil + return mCopy.Interface(), nil }