proto: add Equal
Add support for basic equality comparison of messages.
Messages are equal if they have the same type and marshal to the
same bytes with deterministic serialization, with some exceptions:
- Messages with different registered extensions are unequal.
- NaN is not equal to itself.
Unlike the v1 Equal, a nil message is equal to an empty message of
the same type.
Change-Id: Ibabdadd8c767b801051b8241aeae1ba077e58121
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/174277
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/internal/testprotos/test/test.pb.go b/internal/testprotos/test/test.pb.go
index 263dd3a..454e974 100644
--- a/internal/testprotos/test/test.pb.go
+++ b/internal/testprotos/test/test.pb.go
@@ -2019,6 +2019,126 @@
},
{
ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*int32)(nil),
+ Field: 81,
+ Name: "goproto.proto.test.default_int32_extension",
+ Tag: "varint,81,opt,name=default_int32_extension,def=81",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*int64)(nil),
+ Field: 82,
+ Name: "goproto.proto.test.default_int64_extension",
+ Tag: "varint,82,opt,name=default_int64_extension,def=82",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*uint32)(nil),
+ Field: 83,
+ Name: "goproto.proto.test.default_uint32_extension",
+ Tag: "varint,83,opt,name=default_uint32_extension,def=83",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*uint64)(nil),
+ Field: 84,
+ Name: "goproto.proto.test.default_uint64_extension",
+ Tag: "varint,84,opt,name=default_uint64_extension,def=84",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*int32)(nil),
+ Field: 85,
+ Name: "goproto.proto.test.default_sint32_extension",
+ Tag: "zigzag32,85,opt,name=default_sint32_extension,def=-85",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*int64)(nil),
+ Field: 86,
+ Name: "goproto.proto.test.default_sint64_extension",
+ Tag: "zigzag64,86,opt,name=default_sint64_extension,def=86",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*uint32)(nil),
+ Field: 87,
+ Name: "goproto.proto.test.default_fixed32_extension",
+ Tag: "fixed32,87,opt,name=default_fixed32_extension,def=87",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*uint64)(nil),
+ Field: 88,
+ Name: "goproto.proto.test.default_fixed64_extension",
+ Tag: "fixed64,88,opt,name=default_fixed64_extension,def=88",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*int32)(nil),
+ Field: 89,
+ Name: "goproto.proto.test.default_sfixed32_extension",
+ Tag: "fixed32,89,opt,name=default_sfixed32_extension,def=89",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*int64)(nil),
+ Field: 80,
+ Name: "goproto.proto.test.default_sfixed64_extension",
+ Tag: "fixed64,80,opt,name=default_sfixed64_extension,def=-90",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*float32)(nil),
+ Field: 91,
+ Name: "goproto.proto.test.default_float_extension",
+ Tag: "fixed32,91,opt,name=default_float_extension,def=91.5",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*float64)(nil),
+ Field: 92,
+ Name: "goproto.proto.test.default_double_extension",
+ Tag: "fixed64,92,opt,name=default_double_extension,def=92000",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*bool)(nil),
+ Field: 93,
+ Name: "goproto.proto.test.default_bool_extension",
+ Tag: "varint,93,opt,name=default_bool_extension,def=1",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: (*string)(nil),
+ Field: 94,
+ Name: "goproto.proto.test.default_string_extension",
+ Tag: "bytes,94,opt,name=default_string_extension,def=hello",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
+ ExtensionType: ([]byte)(nil),
+ Field: 95,
+ Name: "goproto.proto.test.default_bytes_extension",
+ Tag: "bytes,95,opt,name=default_bytes_extension,def=world",
+ Filename: "test/test.proto",
+ },
+ {
+ ExtendedType: (*TestAllExtensions)(nil),
ExtensionType: (*string)(nil),
Field: 1003,
Name: "goproto.proto.test.TestNestedExtension.nested_string_extension",
@@ -2151,14 +2271,59 @@
// extend goproto.proto.test.TestAllExtensions { repeated goproto.proto.test.TestAllTypes.NestedEnum repeated_nested_enum_extension = 51; }
E_RepeatedNestedEnumExtension = &file_test_test_proto_extDescs[35]
+ // extend goproto.proto.test.TestAllExtensions { optional int32 default_int32_extension = 81; }
+ E_DefaultInt32Extension = &file_test_test_proto_extDescs[36]
+
+ // extend goproto.proto.test.TestAllExtensions { optional int64 default_int64_extension = 82; }
+ E_DefaultInt64Extension = &file_test_test_proto_extDescs[37]
+
+ // extend goproto.proto.test.TestAllExtensions { optional uint32 default_uint32_extension = 83; }
+ E_DefaultUint32Extension = &file_test_test_proto_extDescs[38]
+
+ // extend goproto.proto.test.TestAllExtensions { optional uint64 default_uint64_extension = 84; }
+ E_DefaultUint64Extension = &file_test_test_proto_extDescs[39]
+
+ // extend goproto.proto.test.TestAllExtensions { optional sint32 default_sint32_extension = 85; }
+ E_DefaultSint32Extension = &file_test_test_proto_extDescs[40]
+
+ // extend goproto.proto.test.TestAllExtensions { optional sint64 default_sint64_extension = 86; }
+ E_DefaultSint64Extension = &file_test_test_proto_extDescs[41]
+
+ // extend goproto.proto.test.TestAllExtensions { optional fixed32 default_fixed32_extension = 87; }
+ E_DefaultFixed32Extension = &file_test_test_proto_extDescs[42]
+
+ // extend goproto.proto.test.TestAllExtensions { optional fixed64 default_fixed64_extension = 88; }
+ E_DefaultFixed64Extension = &file_test_test_proto_extDescs[43]
+
+ // extend goproto.proto.test.TestAllExtensions { optional sfixed32 default_sfixed32_extension = 89; }
+ E_DefaultSfixed32Extension = &file_test_test_proto_extDescs[44]
+
+ // extend goproto.proto.test.TestAllExtensions { optional sfixed64 default_sfixed64_extension = 80; }
+ E_DefaultSfixed64Extension = &file_test_test_proto_extDescs[45]
+
+ // extend goproto.proto.test.TestAllExtensions { optional float default_float_extension = 91; }
+ E_DefaultFloatExtension = &file_test_test_proto_extDescs[46]
+
+ // extend goproto.proto.test.TestAllExtensions { optional double default_double_extension = 92; }
+ E_DefaultDoubleExtension = &file_test_test_proto_extDescs[47]
+
+ // extend goproto.proto.test.TestAllExtensions { optional bool default_bool_extension = 93; }
+ E_DefaultBoolExtension = &file_test_test_proto_extDescs[48]
+
+ // extend goproto.proto.test.TestAllExtensions { optional string default_string_extension = 94; }
+ E_DefaultStringExtension = &file_test_test_proto_extDescs[49]
+
+ // extend goproto.proto.test.TestAllExtensions { optional bytes default_bytes_extension = 95; }
+ E_DefaultBytesExtension = &file_test_test_proto_extDescs[50]
+
// extend goproto.proto.test.TestAllExtensions { optional string nested_string_extension = 1003; }
- E_TestNestedExtension_NestedStringExtension = &file_test_test_proto_extDescs[36]
+ E_TestNestedExtension_NestedStringExtension = &file_test_test_proto_extDescs[51]
// extend goproto.proto.test.TestAllExtensions { optional goproto.proto.test.TestRequired single = 1000; }
- E_TestRequired_Single = &file_test_test_proto_extDescs[37]
+ E_TestRequired_Single = &file_test_test_proto_extDescs[52]
// extend goproto.proto.test.TestAllExtensions { repeated goproto.proto.test.TestRequired multi = 1001; }
- E_TestRequired_Multi = &file_test_test_proto_extDescs[38]
+ E_TestRequired_Multi = &file_test_test_proto_extDescs[53]
)
var File_test_test_proto protoreflect.FileDescriptor
@@ -2969,11 +3134,107 @@
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41,
0x6c, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x45, 0x6e,
0x75, 0x6d, 0x52, 0x1b, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4e, 0x65, 0x73, 0x74,
- 0x65, 0x64, 0x45, 0x6e, 0x75, 0x6d, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x42,
- 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f,
- 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x32,
- 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72,
- 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x50, 0x01, 0x58, 0x02,
+ 0x65, 0x64, 0x45, 0x6e, 0x75, 0x6d, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x3a,
+ 0x61, 0x0a, 0x17, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32,
+ 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x67, 0x6f, 0x70,
+ 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e,
+ 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e,
+ 0x73, 0x18, 0x51, 0x20, 0x01, 0x28, 0x05, 0x3a, 0x02, 0x38, 0x31, 0x52, 0x15, 0x64, 0x65, 0x66,
+ 0x61, 0x75, 0x6c, 0x74, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69,
+ 0x6f, 0x6e, 0x3a, 0x61, 0x0a, 0x17, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x69, 0x6e,
+ 0x74, 0x36, 0x34, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e,
+ 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x65,
+ 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73,
+ 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x52, 0x20, 0x01, 0x28, 0x03, 0x3a, 0x02, 0x38, 0x32, 0x52, 0x15,
+ 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x45, 0x78, 0x74, 0x65,
+ 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x63, 0x0a, 0x18, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74,
+ 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f,
+ 0x6e, 0x12, 0x25, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78,
+ 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x53, 0x20, 0x01, 0x28, 0x0d, 0x3a, 0x02,
+ 0x38, 0x33, 0x52, 0x16, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x55, 0x69, 0x6e, 0x74, 0x33,
+ 0x32, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x63, 0x0a, 0x18, 0x64, 0x65,
+ 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x65, 0x78, 0x74,
+ 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74,
+ 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x54, 0x20,
+ 0x01, 0x28, 0x04, 0x3a, 0x02, 0x38, 0x34, 0x52, 0x16, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74,
+ 0x55, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x3a,
+ 0x64, 0x0a, 0x18, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x69, 0x6e, 0x74, 0x33,
+ 0x32, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x67, 0x6f,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74,
+ 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f,
+ 0x6e, 0x73, 0x18, 0x55, 0x20, 0x01, 0x28, 0x11, 0x3a, 0x03, 0x2d, 0x38, 0x35, 0x52, 0x16, 0x64,
+ 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x45, 0x78, 0x74, 0x65,
+ 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x63, 0x0a, 0x18, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74,
+ 0x5f, 0x73, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f,
+ 0x6e, 0x12, 0x25, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78,
+ 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x56, 0x20, 0x01, 0x28, 0x12, 0x3a, 0x02,
+ 0x38, 0x36, 0x52, 0x16, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x69, 0x6e, 0x74, 0x36,
+ 0x34, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x65, 0x0a, 0x19, 0x64, 0x65,
+ 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x65, 0x78,
+ 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73,
+ 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x57,
+ 0x20, 0x01, 0x28, 0x07, 0x3a, 0x02, 0x38, 0x37, 0x52, 0x17, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c,
+ 0x74, 0x46, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f,
+ 0x6e, 0x3a, 0x65, 0x0a, 0x19, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x66, 0x69, 0x78,
+ 0x65, 0x64, 0x36, 0x34, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25,
+ 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74,
+ 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e,
+ 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x58, 0x20, 0x01, 0x28, 0x06, 0x3a, 0x02, 0x38, 0x38, 0x52,
+ 0x17, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x46, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x45,
+ 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x67, 0x0a, 0x1a, 0x64, 0x65, 0x66, 0x61,
+ 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x65, 0x78, 0x74,
+ 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74,
+ 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x59, 0x20,
+ 0x01, 0x28, 0x0f, 0x3a, 0x02, 0x38, 0x39, 0x52, 0x18, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74,
+ 0x53, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f,
+ 0x6e, 0x3a, 0x68, 0x0a, 0x1a, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x66, 0x69,
+ 0x78, 0x65, 0x64, 0x36, 0x34, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12,
+ 0x25, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
+ 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65,
+ 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x50, 0x20, 0x01, 0x28, 0x10, 0x3a, 0x03, 0x2d, 0x39,
+ 0x30, 0x52, 0x18, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x66, 0x69, 0x78, 0x65, 0x64,
+ 0x36, 0x34, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x63, 0x0a, 0x17, 0x64,
+ 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x65, 0x78, 0x74,
+ 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74,
+ 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x5b, 0x20,
+ 0x01, 0x28, 0x02, 0x3a, 0x04, 0x39, 0x31, 0x2e, 0x35, 0x52, 0x15, 0x64, 0x65, 0x66, 0x61, 0x75,
+ 0x6c, 0x74, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e,
+ 0x3a, 0x66, 0x0a, 0x18, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x64, 0x6f, 0x75, 0x62,
+ 0x6c, 0x65, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x67,
+ 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x65, 0x73,
+ 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69,
+ 0x6f, 0x6e, 0x73, 0x18, 0x5c, 0x20, 0x01, 0x28, 0x01, 0x3a, 0x05, 0x39, 0x32, 0x30, 0x30, 0x30,
+ 0x52, 0x16, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x45,
+ 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x61, 0x0a, 0x16, 0x64, 0x65, 0x66, 0x61,
+ 0x75, 0x6c, 0x74, 0x5f, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69,
+ 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f,
+ 0x74, 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x45,
+ 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x5d, 0x20, 0x01, 0x28, 0x08, 0x3a,
+ 0x04, 0x74, 0x72, 0x75, 0x65, 0x52, 0x14, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x42, 0x6f,
+ 0x6f, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x66, 0x0a, 0x18, 0x64,
+ 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x65, 0x78,
+ 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73,
+ 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x5e,
+ 0x20, 0x01, 0x28, 0x09, 0x3a, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x16, 0x64, 0x65, 0x66,
+ 0x61, 0x75, 0x6c, 0x74, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73,
+ 0x69, 0x6f, 0x6e, 0x3a, 0x64, 0x0a, 0x17, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x62,
+ 0x79, 0x74, 0x65, 0x73, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25,
+ 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74,
+ 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e,
+ 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x5f, 0x20, 0x01, 0x28, 0x0c, 0x3a, 0x05, 0x77, 0x6f, 0x72,
+ 0x6c, 0x64, 0x52, 0x15, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73,
+ 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74,
+ 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70,
+ 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x32, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72,
+ 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x74,
+ 0x65, 0x73, 0x74, 0x50, 0x01, 0x58, 0x02,
}
var (
@@ -3071,6 +3332,21 @@
8, // goproto.proto.test.repeatedgroup_extension:extendee -> goproto.proto.test.TestAllExtensions
8, // goproto.proto.test.repeated_nested_message_extension:extendee -> goproto.proto.test.TestAllExtensions
8, // goproto.proto.test.repeated_nested_enum_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_int32_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_int64_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_uint32_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_uint64_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_sint32_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_sint64_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_fixed32_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_fixed64_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_sfixed32_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_sfixed64_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_float_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_double_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_bool_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_string_extension:extendee -> goproto.proto.test.TestAllExtensions
+ 8, // goproto.proto.test.default_bytes_extension:extendee -> goproto.proto.test.TestAllExtensions
8, // goproto.proto.test.TestNestedExtension.nested_string_extension:extendee -> goproto.proto.test.TestAllExtensions
8, // goproto.proto.test.TestRequired.single:extendee -> goproto.proto.test.TestAllExtensions
8, // goproto.proto.test.TestRequired.multi:extendee -> goproto.proto.test.TestAllExtensions
@@ -3142,7 +3418,7 @@
file_test_test_import_proto_init()
file_test_test_public_proto_init()
file_test_test_weak_proto_init()
- extensionTypes := make([]protoreflect.ExtensionType, 39)
+ extensionTypes := make([]protoreflect.ExtensionType, 54)
File_test_test_proto = protoimpl.FileBuilder{
RawDescriptor: file_test_test_proto_rawDesc,
GoTypes: file_test_test_proto_goTypes,
diff --git a/internal/testprotos/test/test.proto b/internal/testprotos/test/test.proto
index c6b2d6a..de32b96 100644
--- a/internal/testprotos/test/test.proto
+++ b/internal/testprotos/test/test.proto
@@ -210,6 +210,22 @@
repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 48;
repeated TestAllTypes.NestedEnum repeated_nested_enum_extension = 51;
+
+ optional int32 default_int32_extension = 81 [default = 81 ];
+ optional int64 default_int64_extension = 82 [default = 82 ];
+ optional uint32 default_uint32_extension = 83 [default = 83 ];
+ optional uint64 default_uint64_extension = 84 [default = 84 ];
+ optional sint32 default_sint32_extension = 85 [default = -85 ];
+ optional sint64 default_sint64_extension = 86 [default = 86 ];
+ optional fixed32 default_fixed32_extension = 87 [default = 87 ];
+ optional fixed64 default_fixed64_extension = 88 [default = 88 ];
+ optional sfixed32 default_sfixed32_extension = 89 [default = 89 ];
+ optional sfixed64 default_sfixed64_extension = 80 [default = -90 ];
+ optional float default_float_extension = 91 [default = 91.5 ];
+ optional double default_double_extension = 92 [default = 92e3 ];
+ optional bool default_bool_extension = 93 [default = true ];
+ optional string default_string_extension = 94 [default = "hello"];
+ optional bytes default_bytes_extension = 95 [default = "world"];
}
message TestNestedExtension {