From b238255c8b864b12b3b9983fc949617b3d670cfa Mon Sep 17 00:00:00 2001 From: Eitan Yarmush Date: Mon, 30 Nov 2020 19:45:46 -0500 Subject: [PATCH] fix-range-primitives (#9) --- templates/equal/render.go | 10 ++-- tests/api/hello.pb.equal.go | 31 ++++++++---- tests/api/hello.pb.go | 99 ++++++++++++++++++++----------------- tests/api/hello.pb.hash.go | 33 +++++++------ tests/api/hello.pb.merge.go | 10 ++-- tests/api/hello.proto | 5 +- 6 files changed, 110 insertions(+), 78 deletions(-) diff --git a/templates/equal/render.go b/templates/equal/render.go index cec56ae..ce6a74b 100644 --- a/templates/equal/render.go +++ b/templates/equal/render.go @@ -19,15 +19,15 @@ type Value struct { func (fns goSharedFuncs) render(field pgs.Field) (string, error) { var tpl *template.Template - if field.Type().ProtoType().IsNumeric() || + if field.Type().IsRepeated() { + return fns.renderRepeated(field) + } else if field.Type().IsMap() { + return fns.renderMap(field) + } else if field.Type().ProtoType().IsNumeric() || field.Type().ProtoType() == pgs.BoolT || field.Type().IsEnum() { tpl = template.Must(fns.tpl.New("primitive").Parse(primitiveTmpl)) - } else if field.Type().IsMap() { - return fns.renderMap(field) - } else if field.Type().IsRepeated() { - return fns.renderRepeated(field) } else { switch field.Type().ProtoType() { case pgs.BytesT: diff --git a/tests/api/hello.pb.equal.go b/tests/api/hello.pb.equal.go index 74fc939..9ffae3c 100644 --- a/tests/api/hello.pb.equal.go +++ b/tests/api/hello.pb.equal.go @@ -148,16 +148,6 @@ func (m *Nested) Equal(that interface{}) bool { } } - if h, ok := interface{}(m.GetDetails()).(equality.Equalizer); ok { - if !h.Equal(target.GetDetails()) { - return false - } - } else { - if !proto.Equal(m.GetDetails(), target.GetDetails()) { - return false - } - } - if m.GetTest() != target.GetTest() { return false } @@ -183,6 +173,16 @@ func (m *Nested) Equal(that interface{}) bool { } + if h, ok := interface{}(m.GetDetails()).(equality.Equalizer); ok { + if !h.Equal(target.GetDetails()) { + return false + } + } else { + if !proto.Equal(m.GetDetails(), target.GetDetails()) { + return false + } + } + if h, ok := interface{}(m.GetSkipper()).(equality.Equalizer); ok { if !h.Equal(target.GetSkipper()) { return false @@ -238,6 +238,17 @@ func (m *Nested) Equal(that interface{}) bool { } + if len(m.GetRepeatedPrimitive()) != len(target.GetRepeatedPrimitive()) { + return false + } + for idx, v := range m.GetRepeatedPrimitive() { + + if v != target.GetRepeatedPrimitive()[idx] { + return false + } + + } + switch m.TestOneOf.(type) { case *Nested_EmptyOneOf: diff --git a/tests/api/hello.pb.go b/tests/api/hello.pb.go index 7ff7801..8358bbd 100644 --- a/tests/api/hello.pb.go +++ b/tests/api/hello.pb.go @@ -257,10 +257,10 @@ type Nested struct { unknownFields protoimpl.UnknownFields Simple *Simple `protobuf:"bytes,1,opt,name=simple,proto3" json:"simple,omitempty"` - Details *_struct.Struct `protobuf:"bytes,5,opt,name=details,proto3" json:"details,omitempty"` Test Test `protobuf:"varint,2,opt,name=test,proto3,enum=envoy.type.Test" json:"test,omitempty"` Empty *Empty `protobuf:"bytes,3,opt,name=empty,proto3" json:"empty,omitempty"` Hello []string `protobuf:"bytes,4,rep,name=hello,proto3" json:"hello,omitempty"` + Details *_struct.Struct `protobuf:"bytes,5,opt,name=details,proto3" json:"details,omitempty"` Skipper *Simple `protobuf:"bytes,6,opt,name=skipper,proto3" json:"skipper,omitempty"` X []*Simple `protobuf:"bytes,7,rep,name=x,proto3" json:"x,omitempty"` Initial map[string]*Simple `protobuf:"bytes,9,rep,name=initial,proto3" json:"initial,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` @@ -268,7 +268,8 @@ type Nested struct { // Types that are assignable to TestOneOf: // *Nested_EmptyOneOf // *Nested_NestedOneOf - TestOneOf isNested_TestOneOf `protobuf_oneof:"test_one_of"` + TestOneOf isNested_TestOneOf `protobuf_oneof:"test_one_of"` + RepeatedPrimitive []uint64 `protobuf:"varint,13,rep,packed,name=repeated_primitive,json=repeatedPrimitive,proto3" json:"repeated_primitive,omitempty"` } func (x *Nested) Reset() { @@ -310,13 +311,6 @@ func (x *Nested) GetSimple() *Simple { return nil } -func (x *Nested) GetDetails() *_struct.Struct { - if x != nil { - return x.Details - } - return nil -} - func (x *Nested) GetTest() Test { if x != nil { return x.Test @@ -338,6 +332,13 @@ func (x *Nested) GetHello() []string { return nil } +func (x *Nested) GetDetails() *_struct.Struct { + if x != nil { + return x.Details + } + return nil +} + func (x *Nested) GetSkipper() *Simple { if x != nil { return x.Skipper @@ -387,6 +388,13 @@ func (x *Nested) GetNestedOneOf() *NestedEmpty { return nil } +func (x *Nested) GetRepeatedPrimitive() []uint64 { + if x != nil { + return x.RepeatedPrimitive + } + return nil +} + type isNested_TestOneOf interface { isNested_TestOneOf() } @@ -530,20 +538,20 @@ var file_tests_api_hello_proto_rawDesc = []byte{ 0x09, 0x42, 0x04, 0xb8, 0xf5, 0x04, 0x01, 0x52, 0x0a, 0x73, 0x74, 0x72, 0x53, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x12, 0x25, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x5f, 0x73, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x04, 0xb8, 0xf5, 0x04, 0x01, 0x52, 0x0a, - 0x69, 0x6e, 0x74, 0x53, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x22, 0xc4, 0x05, 0x0a, 0x06, 0x4e, + 0x69, 0x6e, 0x74, 0x53, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x22, 0xf3, 0x05, 0x0a, 0x06, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x06, 0x73, 0x69, 0x6d, 0x70, 0x6c, - 0x65, 0x12, 0x31, 0x0a, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x07, 0x64, 0x65, 0x74, - 0x61, 0x69, 0x6c, 0x73, 0x12, 0x24, 0x0a, 0x04, 0x74, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, - 0x54, 0x65, 0x73, 0x74, 0x52, 0x04, 0x74, 0x65, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x05, 0x65, 0x6d, - 0x70, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x65, 0x6e, 0x76, 0x6f, - 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x04, 0xc8, 0xf5, - 0x04, 0x01, 0x52, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x68, 0x65, 0x6c, - 0x6c, 0x6f, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x12, + 0x65, 0x12, 0x24, 0x0a, 0x04, 0x74, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x10, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x54, 0x65, 0x73, + 0x74, 0x52, 0x04, 0x74, 0x65, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, + 0x79, 0x70, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x04, 0xc8, 0xf5, 0x04, 0x01, 0x52, + 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x18, + 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x31, 0x0a, 0x07, + 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x32, 0x0a, 0x07, 0x73, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x42, 0x04, 0xb8, 0xf5, 0x04, 0x01, 0x52, 0x07, 0x73, 0x6b, 0x69, 0x70, @@ -565,27 +573,30 @@ var file_tests_api_hello_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x65, 0x5f, 0x6f, 0x66, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x48, 0x00, 0x52, 0x0b, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4f, - 0x6e, 0x65, 0x4f, 0x66, 0x1a, 0x4e, 0x0a, 0x0c, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x28, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, - 0x70, 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x61, - 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, - 0x38, 0x01, 0x42, 0x0d, 0x0a, 0x0b, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x6f, 0x6e, 0x65, 0x5f, 0x6f, - 0x66, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x39, 0x0a, 0x0b, 0x4e, 0x65, - 0x73, 0x74, 0x65, 0x64, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x06, 0x6e, 0x65, 0x73, - 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x65, 0x6e, 0x76, 0x6f, - 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x06, 0x6e, - 0x65, 0x73, 0x74, 0x65, 0x64, 0x2a, 0x1c, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x09, 0x0a, - 0x05, 0x48, 0x45, 0x4c, 0x4c, 0x4f, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x57, 0x4f, 0x52, 0x4c, - 0x44, 0x10, 0x01, 0x42, 0x39, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x73, 0x6f, 0x6c, 0x6f, 0x2d, 0x69, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, - 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x61, - 0x70, 0x69, 0xb8, 0xf5, 0x04, 0x01, 0xc8, 0xf5, 0x04, 0x01, 0xc0, 0xf5, 0x04, 0x01, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x65, 0x4f, 0x66, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, + 0x5f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x04, + 0x52, 0x11, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x50, 0x72, 0x69, 0x6d, 0x69, 0x74, + 0x69, 0x76, 0x65, 0x1a, 0x4e, 0x0a, 0x0c, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x28, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, + 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, + 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x61, 0x70, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x42, 0x0d, 0x0a, 0x0b, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x6f, 0x6e, 0x65, 0x5f, 0x6f, 0x66, + 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x39, 0x0a, 0x0b, 0x4e, 0x65, 0x73, + 0x74, 0x65, 0x64, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x06, 0x6e, 0x65, 0x73, 0x74, + 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, + 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x06, 0x6e, 0x65, + 0x73, 0x74, 0x65, 0x64, 0x2a, 0x1c, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x09, 0x0a, 0x05, + 0x48, 0x45, 0x4c, 0x4c, 0x4f, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x57, 0x4f, 0x52, 0x4c, 0x44, + 0x10, 0x01, 0x42, 0x39, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x73, 0x6f, 0x6c, 0x6f, 0x2d, 0x69, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, + 0x67, 0x65, 0x6e, 0x2d, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x61, 0x70, + 0x69, 0xb8, 0xf5, 0x04, 0x01, 0xc8, 0xf5, 0x04, 0x01, 0xc0, 0xf5, 0x04, 0x01, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -614,9 +625,9 @@ var file_tests_api_hello_proto_goTypes = []interface{}{ } var file_tests_api_hello_proto_depIdxs = []int32{ 1, // 0: envoy.type.Nested.simple:type_name -> envoy.type.Simple - 7, // 1: envoy.type.Nested.details:type_name -> google.protobuf.Struct - 0, // 2: envoy.type.Nested.test:type_name -> envoy.type.Test - 3, // 3: envoy.type.Nested.empty:type_name -> envoy.type.Empty + 0, // 1: envoy.type.Nested.test:type_name -> envoy.type.Test + 3, // 2: envoy.type.Nested.empty:type_name -> envoy.type.Empty + 7, // 3: envoy.type.Nested.details:type_name -> google.protobuf.Struct 1, // 4: envoy.type.Nested.skipper:type_name -> envoy.type.Simple 1, // 5: envoy.type.Nested.x:type_name -> envoy.type.Simple 5, // 6: envoy.type.Nested.initial:type_name -> envoy.type.Nested.InitialEntry diff --git a/tests/api/hello.pb.hash.go b/tests/api/hello.pb.hash.go index ed0f4b5..c389c79 100644 --- a/tests/api/hello.pb.hash.go +++ b/tests/api/hello.pb.hash.go @@ -141,20 +141,6 @@ func (m *Nested) Hash(hasher hash.Hash64) (uint64, error) { } } - if h, ok := interface{}(m.GetDetails()).(safe_hasher.SafeHasher); ok { - if _, err = h.Hash(hasher); err != nil { - return 0, err - } - } else { - if val, err := hashstructure.Hash(m.GetDetails(), nil); err != nil { - return 0, err - } else { - if err := binary.Write(hasher, binary.LittleEndian, val); err != nil { - return 0, err - } - } - } - err = binary.Write(hasher, binary.LittleEndian, m.GetTest()) if err != nil { return 0, err @@ -182,6 +168,20 @@ func (m *Nested) Hash(hasher hash.Hash64) (uint64, error) { } + if h, ok := interface{}(m.GetDetails()).(safe_hasher.SafeHasher); ok { + if _, err = h.Hash(hasher); err != nil { + return 0, err + } + } else { + if val, err := hashstructure.Hash(m.GetDetails(), nil); err != nil { + return 0, err + } else { + if err := binary.Write(hasher, binary.LittleEndian, val); err != nil { + return 0, err + } + } + } + for _, v := range m.GetX() { if h, ok := interface{}(v).(safe_hasher.SafeHasher); ok { @@ -256,6 +256,11 @@ func (m *Nested) Hash(hasher hash.Hash64) (uint64, error) { } + err = binary.Write(hasher, binary.LittleEndian, m.GetRepeatedPrimitive()) + if err != nil { + return 0, err + } + switch m.TestOneOf.(type) { case *Nested_EmptyOneOf: diff --git a/tests/api/hello.pb.merge.go b/tests/api/hello.pb.merge.go index 1ac4b9b..1e4a5d5 100644 --- a/tests/api/hello.pb.merge.go +++ b/tests/api/hello.pb.merge.go @@ -55,10 +55,6 @@ func (m *Nested) Merge(overrides *Nested) { m.Simple = overrides.Simple } - if overrides.Details != nil { - m.Details = overrides.Details - } - m.Test = overrides.Test if overrides.Empty != nil { @@ -67,6 +63,10 @@ func (m *Nested) Merge(overrides *Nested) { m.Hello = overrides.Hello + if overrides.Details != nil { + m.Details = overrides.Details + } + if overrides.Skipper != nil { m.Skipper = overrides.Skipper } @@ -83,6 +83,8 @@ func (m *Nested) Merge(overrides *Nested) { m.SimpleMap = overrides.SimpleMap } + m.RepeatedPrimitive = overrides.RepeatedPrimitive + if overrides.TestOneOf != nil { m.TestOneOf = overrides.TestOneOf } diff --git a/tests/api/hello.proto b/tests/api/hello.proto index 857431c..6cde105 100644 --- a/tests/api/hello.proto +++ b/tests/api/hello.proto @@ -43,7 +43,6 @@ enum Test { message Nested { Simple simple = 1; - google.protobuf.Struct details = 5; Test test = 2; @@ -51,6 +50,8 @@ message Nested { repeated string hello = 4; + google.protobuf.Struct details = 5; + Simple skipper = 6 [(extproto.skip_hashing) = true]; repeated Simple x = 7 [(extproto.sensitive) = true]; @@ -63,6 +64,8 @@ message Nested { Empty empty_one_of = 11; NestedEmpty nested_one_of = 12; } + + repeated uint64 repeated_primitive = 13; }