From cfd576d1970dad6b11d93c44833c72cab8f0ccd3 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 22 Sep 2021 02:19:49 +0300 Subject: [PATCH] fixup Signed-off-by: Vasiliy Tolstov --- jsonpb.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/jsonpb.go b/jsonpb.go index 7fb0653..f966b70 100644 --- a/jsonpb.go +++ b/jsonpb.go @@ -39,16 +39,17 @@ func (c *jsonpbCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, erro case *codec.Frame: return m.Data, nil case proto.Message: - if nv, nerr := rutil.StructFieldByTag(m, codec.DefaultTagName, flattenTag); nerr == nil { - if nm, ok := nv.(proto.Message); ok { - m = nm - } - } options := c.opts for _, o := range opts { o(&options) } + if nv, nerr := rutil.StructFieldByTag(m, options.TagName, flattenTag); nerr == nil { + if nm, ok := nv.(proto.Message); ok { + m = nm + } + } + marshalOptions := DefaultMarshalOptions if options.Context != nil { if f, ok := options.Context.Value(marshalOptionsKey{}).(jsonpb.MarshalOptions); ok { @@ -72,17 +73,17 @@ func (c *jsonpbCodec) Unmarshal(d []byte, v interface{}, opts ...codec.Option) e m.Data = d return nil case proto.Message: - if nv, nerr := rutil.StructFieldByTag(m, codec.DefaultTagName, flattenTag); nerr == nil { - if nm, ok := nv.(proto.Message); ok { - m = nm - } - } - options := c.opts for _, o := range opts { o(&options) } + if nv, nerr := rutil.StructFieldByTag(m, options.TagName, flattenTag); nerr == nil { + if nm, ok := nv.(proto.Message); ok { + m = nm + } + } + unmarshalOptions := DefaultUnmarshalOptions if options.Context != nil { if f, ok := options.Context.Value(unmarshalOptionsKey{}).(jsonpb.UnmarshalOptions); ok {