cmd/protoc-gen-go: used named types for special fields
Using a named fields gives us the flexibility to change the underlying
representation of special fields without needing to regenerate user code.
We add a named type for ExtensionFields, UnknownFields, and SizeCache.
Change-Id: I107cf82899850ea76665310ce79def60f0f7ab97
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/172402
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/testprotos/test3/test.pb.go b/internal/testprotos/test3/test.pb.go
index d2d2a61..d871a2e 100644
--- a/internal/testprotos/test3/test.pb.go
+++ b/internal/testprotos/test3/test.pb.go
@@ -169,8 +169,8 @@
// *TestAllTypes_OneofEnum
OneofField isTestAllTypes_OneofField `protobuf_oneof:"oneof_field"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
- XXX_unrecognized []byte `json:"-"`
- XXX_sizecache int32 `json:"-"`
+ XXX_unrecognized protoimpl.UnknownFields `json:"-"`
+ XXX_sizecache protoimpl.SizeCache `json:"-"`
}
func (x *TestAllTypes) Reset() {
@@ -753,11 +753,11 @@
func (*TestAllTypes_OneofEnum) isTestAllTypes_OneofField() {}
type ForeignMessage struct {
- C int32 `protobuf:"varint,1,opt,name=c,proto3" json:"c,omitempty"`
- D int32 `protobuf:"varint,2,opt,name=d,proto3" json:"d,omitempty"`
- XXX_NoUnkeyedLiteral struct{} `json:"-"`
- XXX_unrecognized []byte `json:"-"`
- XXX_sizecache int32 `json:"-"`
+ C int32 `protobuf:"varint,1,opt,name=c,proto3" json:"c,omitempty"`
+ D int32 `protobuf:"varint,2,opt,name=d,proto3" json:"d,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized protoimpl.UnknownFields `json:"-"`
+ XXX_sizecache protoimpl.SizeCache `json:"-"`
}
func (x *ForeignMessage) Reset() {
@@ -798,11 +798,11 @@
}
type TestAllTypes_NestedMessage struct {
- A int32 `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"`
- Corecursive *TestAllTypes `protobuf:"bytes,2,opt,name=corecursive,proto3" json:"corecursive,omitempty"`
- XXX_NoUnkeyedLiteral struct{} `json:"-"`
- XXX_unrecognized []byte `json:"-"`
- XXX_sizecache int32 `json:"-"`
+ A int32 `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"`
+ Corecursive *TestAllTypes `protobuf:"bytes,2,opt,name=corecursive,proto3" json:"corecursive,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized protoimpl.UnknownFields `json:"-"`
+ XXX_sizecache protoimpl.SizeCache `json:"-"`
}
func (x *TestAllTypes_NestedMessage) Reset() {
diff --git a/internal/testprotos/test3/test_import.pb.go b/internal/testprotos/test3/test_import.pb.go
index 2ee6535..385827b 100644
--- a/internal/testprotos/test3/test_import.pb.go
+++ b/internal/testprotos/test3/test_import.pb.go
@@ -47,9 +47,9 @@
}
type ImportMessage struct {
- XXX_NoUnkeyedLiteral struct{} `json:"-"`
- XXX_unrecognized []byte `json:"-"`
- XXX_sizecache int32 `json:"-"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized protoimpl.UnknownFields `json:"-"`
+ XXX_sizecache protoimpl.SizeCache `json:"-"`
}
func (x *ImportMessage) Reset() {