Browse Source

goprotobuf: Preserve unknown fields in groups, and generate repeated field getters.

Also make receiver names idiomatic.

R=r
CC=golang-dev
https://codereview.appspot.com/7922045
David Symonds 13 years ago
parent
commit
22e7eb4717

File diff suppressed because it is too large
+ 437 - 237
proto/testdata/test.pb.go


+ 381 - 220
protoc-gen-go/descriptor/descriptor.pb.go

@@ -219,9 +219,16 @@ type FileDescriptorSet struct {
 	XXX_unrecognized []byte                 `json:"-"`
 }
 
-func (this *FileDescriptorSet) Reset()         { *this = FileDescriptorSet{} }
-func (this *FileDescriptorSet) String() string { return proto.CompactTextString(this) }
-func (*FileDescriptorSet) ProtoMessage()       {}
+func (m *FileDescriptorSet) Reset()         { *m = FileDescriptorSet{} }
+func (m *FileDescriptorSet) String() string { return proto.CompactTextString(m) }
+func (*FileDescriptorSet) ProtoMessage()    {}
+
+func (m *FileDescriptorSet) GetFile() []*FileDescriptorProto {
+	if m != nil {
+		return m.File
+	}
+	return nil
+}
 
 type FileDescriptorProto struct {
 	Name             *string                   `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
@@ -237,27 +244,76 @@ type FileDescriptorProto struct {
 	XXX_unrecognized []byte                    `json:"-"`
 }
 
-func (this *FileDescriptorProto) Reset()         { *this = FileDescriptorProto{} }
-func (this *FileDescriptorProto) String() string { return proto.CompactTextString(this) }
-func (*FileDescriptorProto) ProtoMessage()       {}
+func (m *FileDescriptorProto) Reset()         { *m = FileDescriptorProto{} }
+func (m *FileDescriptorProto) String() string { return proto.CompactTextString(m) }
+func (*FileDescriptorProto) ProtoMessage()    {}
 
-func (this *FileDescriptorProto) GetName() string {
-	if this != nil && this.Name != nil {
-		return *this.Name
+func (m *FileDescriptorProto) GetName() string {
+	if m != nil && m.Name != nil {
+		return *m.Name
 	}
 	return ""
 }
 
-func (this *FileDescriptorProto) GetPackage() string {
-	if this != nil && this.Package != nil {
-		return *this.Package
+func (m *FileDescriptorProto) GetPackage() string {
+	if m != nil && m.Package != nil {
+		return *m.Package
 	}
 	return ""
 }
 
-func (this *FileDescriptorProto) GetOptions() *FileOptions {
-	if this != nil {
-		return this.Options
+func (m *FileDescriptorProto) GetDependency() []string {
+	if m != nil {
+		return m.Dependency
+	}
+	return nil
+}
+
+func (m *FileDescriptorProto) GetPublicDependency() []int32 {
+	if m != nil {
+		return m.PublicDependency
+	}
+	return nil
+}
+
+func (m *FileDescriptorProto) GetWeakDependency() []int32 {
+	if m != nil {
+		return m.WeakDependency
+	}
+	return nil
+}
+
+func (m *FileDescriptorProto) GetMessageType() []*DescriptorProto {
+	if m != nil {
+		return m.MessageType
+	}
+	return nil
+}
+
+func (m *FileDescriptorProto) GetEnumType() []*EnumDescriptorProto {
+	if m != nil {
+		return m.EnumType
+	}
+	return nil
+}
+
+func (m *FileDescriptorProto) GetService() []*ServiceDescriptorProto {
+	if m != nil {
+		return m.Service
+	}
+	return nil
+}
+
+func (m *FileDescriptorProto) GetExtension() []*FieldDescriptorProto {
+	if m != nil {
+		return m.Extension
+	}
+	return nil
+}
+
+func (m *FileDescriptorProto) GetOptions() *FileOptions {
+	if m != nil {
+		return m.Options
 	}
 	return nil
 }
@@ -273,20 +329,55 @@ type DescriptorProto struct {
 	XXX_unrecognized []byte                            `json:"-"`
 }
 
-func (this *DescriptorProto) Reset()         { *this = DescriptorProto{} }
-func (this *DescriptorProto) String() string { return proto.CompactTextString(this) }
-func (*DescriptorProto) ProtoMessage()       {}
+func (m *DescriptorProto) Reset()         { *m = DescriptorProto{} }
+func (m *DescriptorProto) String() string { return proto.CompactTextString(m) }
+func (*DescriptorProto) ProtoMessage()    {}
 
-func (this *DescriptorProto) GetName() string {
-	if this != nil && this.Name != nil {
-		return *this.Name
+func (m *DescriptorProto) GetName() string {
+	if m != nil && m.Name != nil {
+		return *m.Name
 	}
 	return ""
 }
 
-func (this *DescriptorProto) GetOptions() *MessageOptions {
-	if this != nil {
-		return this.Options
+func (m *DescriptorProto) GetField() []*FieldDescriptorProto {
+	if m != nil {
+		return m.Field
+	}
+	return nil
+}
+
+func (m *DescriptorProto) GetExtension() []*FieldDescriptorProto {
+	if m != nil {
+		return m.Extension
+	}
+	return nil
+}
+
+func (m *DescriptorProto) GetNestedType() []*DescriptorProto {
+	if m != nil {
+		return m.NestedType
+	}
+	return nil
+}
+
+func (m *DescriptorProto) GetEnumType() []*EnumDescriptorProto {
+	if m != nil {
+		return m.EnumType
+	}
+	return nil
+}
+
+func (m *DescriptorProto) GetExtensionRange() []*DescriptorProto_ExtensionRange {
+	if m != nil {
+		return m.ExtensionRange
+	}
+	return nil
+}
+
+func (m *DescriptorProto) GetOptions() *MessageOptions {
+	if m != nil {
+		return m.Options
 	}
 	return nil
 }
@@ -297,20 +388,20 @@ type DescriptorProto_ExtensionRange struct {
 	XXX_unrecognized []byte `json:"-"`
 }
 
-func (this *DescriptorProto_ExtensionRange) Reset()         { *this = DescriptorProto_ExtensionRange{} }
-func (this *DescriptorProto_ExtensionRange) String() string { return proto.CompactTextString(this) }
-func (*DescriptorProto_ExtensionRange) ProtoMessage()       {}
+func (m *DescriptorProto_ExtensionRange) Reset()         { *m = DescriptorProto_ExtensionRange{} }
+func (m *DescriptorProto_ExtensionRange) String() string { return proto.CompactTextString(m) }
+func (*DescriptorProto_ExtensionRange) ProtoMessage()    {}
 
-func (this *DescriptorProto_ExtensionRange) GetStart() int32 {
-	if this != nil && this.Start != nil {
-		return *this.Start
+func (m *DescriptorProto_ExtensionRange) GetStart() int32 {
+	if m != nil && m.Start != nil {
+		return *m.Start
 	}
 	return 0
 }
 
-func (this *DescriptorProto_ExtensionRange) GetEnd() int32 {
-	if this != nil && this.End != nil {
-		return *this.End
+func (m *DescriptorProto_ExtensionRange) GetEnd() int32 {
+	if m != nil && m.End != nil {
+		return *m.End
 	}
 	return 0
 }
@@ -327,62 +418,62 @@ type FieldDescriptorProto struct {
 	XXX_unrecognized []byte                      `json:"-"`
 }
 
-func (this *FieldDescriptorProto) Reset()         { *this = FieldDescriptorProto{} }
-func (this *FieldDescriptorProto) String() string { return proto.CompactTextString(this) }
-func (*FieldDescriptorProto) ProtoMessage()       {}
+func (m *FieldDescriptorProto) Reset()         { *m = FieldDescriptorProto{} }
+func (m *FieldDescriptorProto) String() string { return proto.CompactTextString(m) }
+func (*FieldDescriptorProto) ProtoMessage()    {}
 
-func (this *FieldDescriptorProto) GetName() string {
-	if this != nil && this.Name != nil {
-		return *this.Name
+func (m *FieldDescriptorProto) GetName() string {
+	if m != nil && m.Name != nil {
+		return *m.Name
 	}
 	return ""
 }
 
-func (this *FieldDescriptorProto) GetNumber() int32 {
-	if this != nil && this.Number != nil {
-		return *this.Number
+func (m *FieldDescriptorProto) GetNumber() int32 {
+	if m != nil && m.Number != nil {
+		return *m.Number
 	}
 	return 0
 }
 
-func (this *FieldDescriptorProto) GetLabel() FieldDescriptorProto_Label {
-	if this != nil && this.Label != nil {
-		return *this.Label
+func (m *FieldDescriptorProto) GetLabel() FieldDescriptorProto_Label {
+	if m != nil && m.Label != nil {
+		return *m.Label
 	}
 	return 0
 }
 
-func (this *FieldDescriptorProto) GetType() FieldDescriptorProto_Type {
-	if this != nil && this.Type != nil {
-		return *this.Type
+func (m *FieldDescriptorProto) GetType() FieldDescriptorProto_Type {
+	if m != nil && m.Type != nil {
+		return *m.Type
 	}
 	return 0
 }
 
-func (this *FieldDescriptorProto) GetTypeName() string {
-	if this != nil && this.TypeName != nil {
-		return *this.TypeName
+func (m *FieldDescriptorProto) GetTypeName() string {
+	if m != nil && m.TypeName != nil {
+		return *m.TypeName
 	}
 	return ""
 }
 
-func (this *FieldDescriptorProto) GetExtendee() string {
-	if this != nil && this.Extendee != nil {
-		return *this.Extendee
+func (m *FieldDescriptorProto) GetExtendee() string {
+	if m != nil && m.Extendee != nil {
+		return *m.Extendee
 	}
 	return ""
 }
 
-func (this *FieldDescriptorProto) GetDefaultValue() string {
-	if this != nil && this.DefaultValue != nil {
-		return *this.DefaultValue
+func (m *FieldDescriptorProto) GetDefaultValue() string {
+	if m != nil && m.DefaultValue != nil {
+		return *m.DefaultValue
 	}
 	return ""
 }
 
-func (this *FieldDescriptorProto) GetOptions() *FieldOptions {
-	if this != nil {
-		return this.Options
+func (m *FieldDescriptorProto) GetOptions() *FieldOptions {
+	if m != nil {
+		return m.Options
 	}
 	return nil
 }
@@ -394,20 +485,27 @@ type EnumDescriptorProto struct {
 	XXX_unrecognized []byte                      `json:"-"`
 }
 
-func (this *EnumDescriptorProto) Reset()         { *this = EnumDescriptorProto{} }
-func (this *EnumDescriptorProto) String() string { return proto.CompactTextString(this) }
-func (*EnumDescriptorProto) ProtoMessage()       {}
+func (m *EnumDescriptorProto) Reset()         { *m = EnumDescriptorProto{} }
+func (m *EnumDescriptorProto) String() string { return proto.CompactTextString(m) }
+func (*EnumDescriptorProto) ProtoMessage()    {}
 
-func (this *EnumDescriptorProto) GetName() string {
-	if this != nil && this.Name != nil {
-		return *this.Name
+func (m *EnumDescriptorProto) GetName() string {
+	if m != nil && m.Name != nil {
+		return *m.Name
 	}
 	return ""
 }
 
-func (this *EnumDescriptorProto) GetOptions() *EnumOptions {
-	if this != nil {
-		return this.Options
+func (m *EnumDescriptorProto) GetValue() []*EnumValueDescriptorProto {
+	if m != nil {
+		return m.Value
+	}
+	return nil
+}
+
+func (m *EnumDescriptorProto) GetOptions() *EnumOptions {
+	if m != nil {
+		return m.Options
 	}
 	return nil
 }
@@ -419,27 +517,27 @@ type EnumValueDescriptorProto struct {
 	XXX_unrecognized []byte            `json:"-"`
 }
 
-func (this *EnumValueDescriptorProto) Reset()         { *this = EnumValueDescriptorProto{} }
-func (this *EnumValueDescriptorProto) String() string { return proto.CompactTextString(this) }
-func (*EnumValueDescriptorProto) ProtoMessage()       {}
+func (m *EnumValueDescriptorProto) Reset()         { *m = EnumValueDescriptorProto{} }
+func (m *EnumValueDescriptorProto) String() string { return proto.CompactTextString(m) }
+func (*EnumValueDescriptorProto) ProtoMessage()    {}
 
-func (this *EnumValueDescriptorProto) GetName() string {
-	if this != nil && this.Name != nil {
-		return *this.Name
+func (m *EnumValueDescriptorProto) GetName() string {
+	if m != nil && m.Name != nil {
+		return *m.Name
 	}
 	return ""
 }
 
-func (this *EnumValueDescriptorProto) GetNumber() int32 {
-	if this != nil && this.Number != nil {
-		return *this.Number
+func (m *EnumValueDescriptorProto) GetNumber() int32 {
+	if m != nil && m.Number != nil {
+		return *m.Number
 	}
 	return 0
 }
 
-func (this *EnumValueDescriptorProto) GetOptions() *EnumValueOptions {
-	if this != nil {
-		return this.Options
+func (m *EnumValueDescriptorProto) GetOptions() *EnumValueOptions {
+	if m != nil {
+		return m.Options
 	}
 	return nil
 }
@@ -451,20 +549,27 @@ type ServiceDescriptorProto struct {
 	XXX_unrecognized []byte                   `json:"-"`
 }
 
-func (this *ServiceDescriptorProto) Reset()         { *this = ServiceDescriptorProto{} }
-func (this *ServiceDescriptorProto) String() string { return proto.CompactTextString(this) }
-func (*ServiceDescriptorProto) ProtoMessage()       {}
+func (m *ServiceDescriptorProto) Reset()         { *m = ServiceDescriptorProto{} }
+func (m *ServiceDescriptorProto) String() string { return proto.CompactTextString(m) }
+func (*ServiceDescriptorProto) ProtoMessage()    {}
 
-func (this *ServiceDescriptorProto) GetName() string {
-	if this != nil && this.Name != nil {
-		return *this.Name
+func (m *ServiceDescriptorProto) GetName() string {
+	if m != nil && m.Name != nil {
+		return *m.Name
 	}
 	return ""
 }
 
-func (this *ServiceDescriptorProto) GetOptions() *ServiceOptions {
-	if this != nil {
-		return this.Options
+func (m *ServiceDescriptorProto) GetMethod() []*MethodDescriptorProto {
+	if m != nil {
+		return m.Method
+	}
+	return nil
+}
+
+func (m *ServiceDescriptorProto) GetOptions() *ServiceOptions {
+	if m != nil {
+		return m.Options
 	}
 	return nil
 }
@@ -477,34 +582,34 @@ type MethodDescriptorProto struct {
 	XXX_unrecognized []byte         `json:"-"`
 }
 
-func (this *MethodDescriptorProto) Reset()         { *this = MethodDescriptorProto{} }
-func (this *MethodDescriptorProto) String() string { return proto.CompactTextString(this) }
-func (*MethodDescriptorProto) ProtoMessage()       {}
+func (m *MethodDescriptorProto) Reset()         { *m = MethodDescriptorProto{} }
+func (m *MethodDescriptorProto) String() string { return proto.CompactTextString(m) }
+func (*MethodDescriptorProto) ProtoMessage()    {}
 
-func (this *MethodDescriptorProto) GetName() string {
-	if this != nil && this.Name != nil {
-		return *this.Name
+func (m *MethodDescriptorProto) GetName() string {
+	if m != nil && m.Name != nil {
+		return *m.Name
 	}
 	return ""
 }
 
-func (this *MethodDescriptorProto) GetInputType() string {
-	if this != nil && this.InputType != nil {
-		return *this.InputType
+func (m *MethodDescriptorProto) GetInputType() string {
+	if m != nil && m.InputType != nil {
+		return *m.InputType
 	}
 	return ""
 }
 
-func (this *MethodDescriptorProto) GetOutputType() string {
-	if this != nil && this.OutputType != nil {
-		return *this.OutputType
+func (m *MethodDescriptorProto) GetOutputType() string {
+	if m != nil && m.OutputType != nil {
+		return *m.OutputType
 	}
 	return ""
 }
 
-func (this *MethodDescriptorProto) GetOptions() *MethodOptions {
-	if this != nil {
-		return this.Options
+func (m *MethodDescriptorProto) GetOptions() *MethodOptions {
+	if m != nil {
+		return m.Options
 	}
 	return nil
 }
@@ -522,9 +627,9 @@ type FileOptions struct {
 	XXX_unrecognized    []byte                    `json:"-"`
 }
 
-func (this *FileOptions) Reset()         { *this = FileOptions{} }
-func (this *FileOptions) String() string { return proto.CompactTextString(this) }
-func (*FileOptions) ProtoMessage()       {}
+func (m *FileOptions) Reset()         { *m = FileOptions{} }
+func (m *FileOptions) String() string { return proto.CompactTextString(m) }
+func (*FileOptions) ProtoMessage()    {}
 
 var extRange_FileOptions = []proto.ExtensionRange{
 	{1000, 536870911},
@@ -533,11 +638,11 @@ var extRange_FileOptions = []proto.ExtensionRange{
 func (*FileOptions) ExtensionRangeArray() []proto.ExtensionRange {
 	return extRange_FileOptions
 }
-func (this *FileOptions) ExtensionMap() map[int32]proto.Extension {
-	if this.XXX_extensions == nil {
-		this.XXX_extensions = make(map[int32]proto.Extension)
+func (m *FileOptions) ExtensionMap() map[int32]proto.Extension {
+	if m.XXX_extensions == nil {
+		m.XXX_extensions = make(map[int32]proto.Extension)
 	}
-	return this.XXX_extensions
+	return m.XXX_extensions
 }
 
 const Default_FileOptions_JavaMultipleFiles bool = false
@@ -546,55 +651,62 @@ const Default_FileOptions_CcGenericServices bool = true
 const Default_FileOptions_JavaGenericServices bool = true
 const Default_FileOptions_PyGenericServices bool = true
 
-func (this *FileOptions) GetJavaPackage() string {
-	if this != nil && this.JavaPackage != nil {
-		return *this.JavaPackage
+func (m *FileOptions) GetJavaPackage() string {
+	if m != nil && m.JavaPackage != nil {
+		return *m.JavaPackage
 	}
 	return ""
 }
 
-func (this *FileOptions) GetJavaOuterClassname() string {
-	if this != nil && this.JavaOuterClassname != nil {
-		return *this.JavaOuterClassname
+func (m *FileOptions) GetJavaOuterClassname() string {
+	if m != nil && m.JavaOuterClassname != nil {
+		return *m.JavaOuterClassname
 	}
 	return ""
 }
 
-func (this *FileOptions) GetJavaMultipleFiles() bool {
-	if this != nil && this.JavaMultipleFiles != nil {
-		return *this.JavaMultipleFiles
+func (m *FileOptions) GetJavaMultipleFiles() bool {
+	if m != nil && m.JavaMultipleFiles != nil {
+		return *m.JavaMultipleFiles
 	}
 	return Default_FileOptions_JavaMultipleFiles
 }
 
-func (this *FileOptions) GetOptimizeFor() FileOptions_OptimizeMode {
-	if this != nil && this.OptimizeFor != nil {
-		return *this.OptimizeFor
+func (m *FileOptions) GetOptimizeFor() FileOptions_OptimizeMode {
+	if m != nil && m.OptimizeFor != nil {
+		return *m.OptimizeFor
 	}
 	return Default_FileOptions_OptimizeFor
 }
 
-func (this *FileOptions) GetCcGenericServices() bool {
-	if this != nil && this.CcGenericServices != nil {
-		return *this.CcGenericServices
+func (m *FileOptions) GetCcGenericServices() bool {
+	if m != nil && m.CcGenericServices != nil {
+		return *m.CcGenericServices
 	}
 	return Default_FileOptions_CcGenericServices
 }
 
-func (this *FileOptions) GetJavaGenericServices() bool {
-	if this != nil && this.JavaGenericServices != nil {
-		return *this.JavaGenericServices
+func (m *FileOptions) GetJavaGenericServices() bool {
+	if m != nil && m.JavaGenericServices != nil {
+		return *m.JavaGenericServices
 	}
 	return Default_FileOptions_JavaGenericServices
 }
 
-func (this *FileOptions) GetPyGenericServices() bool {
-	if this != nil && this.PyGenericServices != nil {
-		return *this.PyGenericServices
+func (m *FileOptions) GetPyGenericServices() bool {
+	if m != nil && m.PyGenericServices != nil {
+		return *m.PyGenericServices
 	}
 	return Default_FileOptions_PyGenericServices
 }
 
+func (m *FileOptions) GetUninterpretedOption() []*UninterpretedOption {
+	if m != nil {
+		return m.UninterpretedOption
+	}
+	return nil
+}
+
 type MessageOptions struct {
 	MessageSetWireFormat         *bool                     `protobuf:"varint,1,opt,name=message_set_wire_format,def=0" json:"message_set_wire_format,omitempty"`
 	NoStandardDescriptorAccessor *bool                     `protobuf:"varint,2,opt,name=no_standard_descriptor_accessor,def=0" json:"no_standard_descriptor_accessor,omitempty"`
@@ -603,9 +715,9 @@ type MessageOptions struct {
 	XXX_unrecognized             []byte                    `json:"-"`
 }
 
-func (this *MessageOptions) Reset()         { *this = MessageOptions{} }
-func (this *MessageOptions) String() string { return proto.CompactTextString(this) }
-func (*MessageOptions) ProtoMessage()       {}
+func (m *MessageOptions) Reset()         { *m = MessageOptions{} }
+func (m *MessageOptions) String() string { return proto.CompactTextString(m) }
+func (*MessageOptions) ProtoMessage()    {}
 
 var extRange_MessageOptions = []proto.ExtensionRange{
 	{1000, 536870911},
@@ -614,30 +726,37 @@ var extRange_MessageOptions = []proto.ExtensionRange{
 func (*MessageOptions) ExtensionRangeArray() []proto.ExtensionRange {
 	return extRange_MessageOptions
 }
-func (this *MessageOptions) ExtensionMap() map[int32]proto.Extension {
-	if this.XXX_extensions == nil {
-		this.XXX_extensions = make(map[int32]proto.Extension)
+func (m *MessageOptions) ExtensionMap() map[int32]proto.Extension {
+	if m.XXX_extensions == nil {
+		m.XXX_extensions = make(map[int32]proto.Extension)
 	}
-	return this.XXX_extensions
+	return m.XXX_extensions
 }
 
 const Default_MessageOptions_MessageSetWireFormat bool = false
 const Default_MessageOptions_NoStandardDescriptorAccessor bool = false
 
-func (this *MessageOptions) GetMessageSetWireFormat() bool {
-	if this != nil && this.MessageSetWireFormat != nil {
-		return *this.MessageSetWireFormat
+func (m *MessageOptions) GetMessageSetWireFormat() bool {
+	if m != nil && m.MessageSetWireFormat != nil {
+		return *m.MessageSetWireFormat
 	}
 	return Default_MessageOptions_MessageSetWireFormat
 }
 
-func (this *MessageOptions) GetNoStandardDescriptorAccessor() bool {
-	if this != nil && this.NoStandardDescriptorAccessor != nil {
-		return *this.NoStandardDescriptorAccessor
+func (m *MessageOptions) GetNoStandardDescriptorAccessor() bool {
+	if m != nil && m.NoStandardDescriptorAccessor != nil {
+		return *m.NoStandardDescriptorAccessor
 	}
 	return Default_MessageOptions_NoStandardDescriptorAccessor
 }
 
+func (m *MessageOptions) GetUninterpretedOption() []*UninterpretedOption {
+	if m != nil {
+		return m.UninterpretedOption
+	}
+	return nil
+}
+
 type FieldOptions struct {
 	Ctype               *FieldOptions_CType       `protobuf:"varint,1,opt,name=ctype,enum=google.protobuf.FieldOptions_CType,def=0" json:"ctype,omitempty"`
 	Packed              *bool                     `protobuf:"varint,2,opt,name=packed" json:"packed,omitempty"`
@@ -648,9 +767,9 @@ type FieldOptions struct {
 	XXX_unrecognized    []byte                    `json:"-"`
 }
 
-func (this *FieldOptions) Reset()         { *this = FieldOptions{} }
-func (this *FieldOptions) String() string { return proto.CompactTextString(this) }
-func (*FieldOptions) ProtoMessage()       {}
+func (m *FieldOptions) Reset()         { *m = FieldOptions{} }
+func (m *FieldOptions) String() string { return proto.CompactTextString(m) }
+func (*FieldOptions) ProtoMessage()    {}
 
 var extRange_FieldOptions = []proto.ExtensionRange{
 	{1000, 536870911},
@@ -659,53 +778,60 @@ var extRange_FieldOptions = []proto.ExtensionRange{
 func (*FieldOptions) ExtensionRangeArray() []proto.ExtensionRange {
 	return extRange_FieldOptions
 }
-func (this *FieldOptions) ExtensionMap() map[int32]proto.Extension {
-	if this.XXX_extensions == nil {
-		this.XXX_extensions = make(map[int32]proto.Extension)
+func (m *FieldOptions) ExtensionMap() map[int32]proto.Extension {
+	if m.XXX_extensions == nil {
+		m.XXX_extensions = make(map[int32]proto.Extension)
 	}
-	return this.XXX_extensions
+	return m.XXX_extensions
 }
 
 const Default_FieldOptions_Ctype FieldOptions_CType = FieldOptions_STRING
 const Default_FieldOptions_Deprecated bool = false
 
-func (this *FieldOptions) GetCtype() FieldOptions_CType {
-	if this != nil && this.Ctype != nil {
-		return *this.Ctype
+func (m *FieldOptions) GetCtype() FieldOptions_CType {
+	if m != nil && m.Ctype != nil {
+		return *m.Ctype
 	}
 	return Default_FieldOptions_Ctype
 }
 
-func (this *FieldOptions) GetPacked() bool {
-	if this != nil && this.Packed != nil {
-		return *this.Packed
+func (m *FieldOptions) GetPacked() bool {
+	if m != nil && m.Packed != nil {
+		return *m.Packed
 	}
 	return false
 }
 
-func (this *FieldOptions) GetDeprecated() bool {
-	if this != nil && this.Deprecated != nil {
-		return *this.Deprecated
+func (m *FieldOptions) GetDeprecated() bool {
+	if m != nil && m.Deprecated != nil {
+		return *m.Deprecated
 	}
 	return Default_FieldOptions_Deprecated
 }
 
-func (this *FieldOptions) GetExperimentalMapKey() string {
-	if this != nil && this.ExperimentalMapKey != nil {
-		return *this.ExperimentalMapKey
+func (m *FieldOptions) GetExperimentalMapKey() string {
+	if m != nil && m.ExperimentalMapKey != nil {
+		return *m.ExperimentalMapKey
 	}
 	return ""
 }
 
+func (m *FieldOptions) GetUninterpretedOption() []*UninterpretedOption {
+	if m != nil {
+		return m.UninterpretedOption
+	}
+	return nil
+}
+
 type EnumOptions struct {
 	UninterpretedOption []*UninterpretedOption    `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"`
 	XXX_extensions      map[int32]proto.Extension `json:"-"`
 	XXX_unrecognized    []byte                    `json:"-"`
 }
 
-func (this *EnumOptions) Reset()         { *this = EnumOptions{} }
-func (this *EnumOptions) String() string { return proto.CompactTextString(this) }
-func (*EnumOptions) ProtoMessage()       {}
+func (m *EnumOptions) Reset()         { *m = EnumOptions{} }
+func (m *EnumOptions) String() string { return proto.CompactTextString(m) }
+func (*EnumOptions) ProtoMessage()    {}
 
 var extRange_EnumOptions = []proto.ExtensionRange{
 	{1000, 536870911},
@@ -714,11 +840,18 @@ var extRange_EnumOptions = []proto.ExtensionRange{
 func (*EnumOptions) ExtensionRangeArray() []proto.ExtensionRange {
 	return extRange_EnumOptions
 }
-func (this *EnumOptions) ExtensionMap() map[int32]proto.Extension {
-	if this.XXX_extensions == nil {
-		this.XXX_extensions = make(map[int32]proto.Extension)
+func (m *EnumOptions) ExtensionMap() map[int32]proto.Extension {
+	if m.XXX_extensions == nil {
+		m.XXX_extensions = make(map[int32]proto.Extension)
+	}
+	return m.XXX_extensions
+}
+
+func (m *EnumOptions) GetUninterpretedOption() []*UninterpretedOption {
+	if m != nil {
+		return m.UninterpretedOption
 	}
-	return this.XXX_extensions
+	return nil
 }
 
 type EnumValueOptions struct {
@@ -727,9 +860,9 @@ type EnumValueOptions struct {
 	XXX_unrecognized    []byte                    `json:"-"`
 }
 
-func (this *EnumValueOptions) Reset()         { *this = EnumValueOptions{} }
-func (this *EnumValueOptions) String() string { return proto.CompactTextString(this) }
-func (*EnumValueOptions) ProtoMessage()       {}
+func (m *EnumValueOptions) Reset()         { *m = EnumValueOptions{} }
+func (m *EnumValueOptions) String() string { return proto.CompactTextString(m) }
+func (*EnumValueOptions) ProtoMessage()    {}
 
 var extRange_EnumValueOptions = []proto.ExtensionRange{
 	{1000, 536870911},
@@ -738,11 +871,18 @@ var extRange_EnumValueOptions = []proto.ExtensionRange{
 func (*EnumValueOptions) ExtensionRangeArray() []proto.ExtensionRange {
 	return extRange_EnumValueOptions
 }
-func (this *EnumValueOptions) ExtensionMap() map[int32]proto.Extension {
-	if this.XXX_extensions == nil {
-		this.XXX_extensions = make(map[int32]proto.Extension)
+func (m *EnumValueOptions) ExtensionMap() map[int32]proto.Extension {
+	if m.XXX_extensions == nil {
+		m.XXX_extensions = make(map[int32]proto.Extension)
+	}
+	return m.XXX_extensions
+}
+
+func (m *EnumValueOptions) GetUninterpretedOption() []*UninterpretedOption {
+	if m != nil {
+		return m.UninterpretedOption
 	}
-	return this.XXX_extensions
+	return nil
 }
 
 type ServiceOptions struct {
@@ -751,9 +891,9 @@ type ServiceOptions struct {
 	XXX_unrecognized    []byte                    `json:"-"`
 }
 
-func (this *ServiceOptions) Reset()         { *this = ServiceOptions{} }
-func (this *ServiceOptions) String() string { return proto.CompactTextString(this) }
-func (*ServiceOptions) ProtoMessage()       {}
+func (m *ServiceOptions) Reset()         { *m = ServiceOptions{} }
+func (m *ServiceOptions) String() string { return proto.CompactTextString(m) }
+func (*ServiceOptions) ProtoMessage()    {}
 
 var extRange_ServiceOptions = []proto.ExtensionRange{
 	{1000, 536870911},
@@ -762,11 +902,18 @@ var extRange_ServiceOptions = []proto.ExtensionRange{
 func (*ServiceOptions) ExtensionRangeArray() []proto.ExtensionRange {
 	return extRange_ServiceOptions
 }
-func (this *ServiceOptions) ExtensionMap() map[int32]proto.Extension {
-	if this.XXX_extensions == nil {
-		this.XXX_extensions = make(map[int32]proto.Extension)
+func (m *ServiceOptions) ExtensionMap() map[int32]proto.Extension {
+	if m.XXX_extensions == nil {
+		m.XXX_extensions = make(map[int32]proto.Extension)
 	}
-	return this.XXX_extensions
+	return m.XXX_extensions
+}
+
+func (m *ServiceOptions) GetUninterpretedOption() []*UninterpretedOption {
+	if m != nil {
+		return m.UninterpretedOption
+	}
+	return nil
 }
 
 type MethodOptions struct {
@@ -775,9 +922,9 @@ type MethodOptions struct {
 	XXX_unrecognized    []byte                    `json:"-"`
 }
 
-func (this *MethodOptions) Reset()         { *this = MethodOptions{} }
-func (this *MethodOptions) String() string { return proto.CompactTextString(this) }
-func (*MethodOptions) ProtoMessage()       {}
+func (m *MethodOptions) Reset()         { *m = MethodOptions{} }
+func (m *MethodOptions) String() string { return proto.CompactTextString(m) }
+func (*MethodOptions) ProtoMessage()    {}
 
 var extRange_MethodOptions = []proto.ExtensionRange{
 	{1000, 536870911},
@@ -786,11 +933,18 @@ var extRange_MethodOptions = []proto.ExtensionRange{
 func (*MethodOptions) ExtensionRangeArray() []proto.ExtensionRange {
 	return extRange_MethodOptions
 }
-func (this *MethodOptions) ExtensionMap() map[int32]proto.Extension {
-	if this.XXX_extensions == nil {
-		this.XXX_extensions = make(map[int32]proto.Extension)
+func (m *MethodOptions) ExtensionMap() map[int32]proto.Extension {
+	if m.XXX_extensions == nil {
+		m.XXX_extensions = make(map[int32]proto.Extension)
 	}
-	return this.XXX_extensions
+	return m.XXX_extensions
+}
+
+func (m *MethodOptions) GetUninterpretedOption() []*UninterpretedOption {
+	if m != nil {
+		return m.UninterpretedOption
+	}
+	return nil
 }
 
 type UninterpretedOption struct {
@@ -803,41 +957,48 @@ type UninterpretedOption struct {
 	XXX_unrecognized []byte                          `json:"-"`
 }
 
-func (this *UninterpretedOption) Reset()         { *this = UninterpretedOption{} }
-func (this *UninterpretedOption) String() string { return proto.CompactTextString(this) }
-func (*UninterpretedOption) ProtoMessage()       {}
+func (m *UninterpretedOption) Reset()         { *m = UninterpretedOption{} }
+func (m *UninterpretedOption) String() string { return proto.CompactTextString(m) }
+func (*UninterpretedOption) ProtoMessage()    {}
+
+func (m *UninterpretedOption) GetName() []*UninterpretedOption_NamePart {
+	if m != nil {
+		return m.Name
+	}
+	return nil
+}
 
-func (this *UninterpretedOption) GetIdentifierValue() string {
-	if this != nil && this.IdentifierValue != nil {
-		return *this.IdentifierValue
+func (m *UninterpretedOption) GetIdentifierValue() string {
+	if m != nil && m.IdentifierValue != nil {
+		return *m.IdentifierValue
 	}
 	return ""
 }
 
-func (this *UninterpretedOption) GetPositiveIntValue() uint64 {
-	if this != nil && this.PositiveIntValue != nil {
-		return *this.PositiveIntValue
+func (m *UninterpretedOption) GetPositiveIntValue() uint64 {
+	if m != nil && m.PositiveIntValue != nil {
+		return *m.PositiveIntValue
 	}
 	return 0
 }
 
-func (this *UninterpretedOption) GetNegativeIntValue() int64 {
-	if this != nil && this.NegativeIntValue != nil {
-		return *this.NegativeIntValue
+func (m *UninterpretedOption) GetNegativeIntValue() int64 {
+	if m != nil && m.NegativeIntValue != nil {
+		return *m.NegativeIntValue
 	}
 	return 0
 }
 
-func (this *UninterpretedOption) GetDoubleValue() float64 {
-	if this != nil && this.DoubleValue != nil {
-		return *this.DoubleValue
+func (m *UninterpretedOption) GetDoubleValue() float64 {
+	if m != nil && m.DoubleValue != nil {
+		return *m.DoubleValue
 	}
 	return 0
 }
 
-func (this *UninterpretedOption) GetStringValue() []byte {
-	if this != nil {
-		return this.StringValue
+func (m *UninterpretedOption) GetStringValue() []byte {
+	if m != nil {
+		return m.StringValue
 	}
 	return nil
 }
@@ -848,20 +1009,20 @@ type UninterpretedOption_NamePart struct {
 	XXX_unrecognized []byte  `json:"-"`
 }
 
-func (this *UninterpretedOption_NamePart) Reset()         { *this = UninterpretedOption_NamePart{} }
-func (this *UninterpretedOption_NamePart) String() string { return proto.CompactTextString(this) }
-func (*UninterpretedOption_NamePart) ProtoMessage()       {}
+func (m *UninterpretedOption_NamePart) Reset()         { *m = UninterpretedOption_NamePart{} }
+func (m *UninterpretedOption_NamePart) String() string { return proto.CompactTextString(m) }
+func (*UninterpretedOption_NamePart) ProtoMessage()    {}
 
-func (this *UninterpretedOption_NamePart) GetNamePart() string {
-	if this != nil && this.NamePart != nil {
-		return *this.NamePart
+func (m *UninterpretedOption_NamePart) GetNamePart() string {
+	if m != nil && m.NamePart != nil {
+		return *m.NamePart
 	}
 	return ""
 }
 
-func (this *UninterpretedOption_NamePart) GetIsExtension() bool {
-	if this != nil && this.IsExtension != nil {
-		return *this.IsExtension
+func (m *UninterpretedOption_NamePart) GetIsExtension() bool {
+	if m != nil && m.IsExtension != nil {
+		return *m.IsExtension
 	}
 	return false
 }

+ 37 - 36
protoc-gen-go/generator/generator.go

@@ -282,19 +282,19 @@ func (ms *messageSymbol) GenerateAlias(g *Generator, pkg string) {
 	remoteSym := pkg + "." + ms.sym
 
 	g.P("type ", ms.sym, " ", remoteSym)
-	g.P("func (this *", ms.sym, ") Reset() { (*", remoteSym, ")(this).Reset() }")
-	g.P("func (this *", ms.sym, ") String() string { return (*", remoteSym, ")(this).String() }")
+	g.P("func (m *", ms.sym, ") Reset() { (*", remoteSym, ")(m).Reset() }")
+	g.P("func (m *", ms.sym, ") String() string { return (*", remoteSym, ")(m).String() }")
 	g.P("func (*", ms.sym, ") ProtoMessage() {}")
 	if ms.hasExtensions {
 		g.P("func (*", ms.sym, ") ExtensionRangeArray() []", g.Pkg["proto"], ".ExtensionRange ",
 			"{ return (*", remoteSym, ")(nil).ExtensionRangeArray() }")
-		g.P("func (this *", ms.sym, ") ExtensionMap() map[int32]", g.Pkg["proto"], ".Extension ",
-			"{ return (*", remoteSym, ")(this).ExtensionMap() }")
+		g.P("func (m *", ms.sym, ") ExtensionMap() map[int32]", g.Pkg["proto"], ".Extension ",
+			"{ return (*", remoteSym, ")(m).ExtensionMap() }")
 		if ms.isMessageSet {
-			g.P("func (this *", ms.sym, ") Marshal() ([]byte, error) ",
-				"{ return (*", remoteSym, ")(this).Marshal() }")
-			g.P("func (this *", ms.sym, ") Unmarshal(buf []byte) error ",
-				"{ return (*", remoteSym, ")(this).Unmarshal(buf) }")
+			g.P("func (m *", ms.sym, ") Marshal() ([]byte, error) ",
+				"{ return (*", remoteSym, ")(m).Marshal() }")
+			g.P("func (m *", ms.sym, ") Unmarshal(buf []byte) error ",
+				"{ return (*", remoteSym, ")(m).Unmarshal(buf) }")
 		}
 	}
 	for _, get := range ms.getters {
@@ -302,7 +302,7 @@ func (ms *messageSymbol) GenerateAlias(g *Generator, pkg string) {
 			g.RecordTypeUse(get.typeName)
 		}
 		typ := get.typ
-		val := "(*" + remoteSym + ")(this)." + get.name + "()"
+		val := "(*" + remoteSym + ")(m)." + get.name + "()"
 		if get.genType {
 			// typ will be "*pkg.T" (message/group) or "pkg.T" (enum).
 			// Either of those might have a "[]" prefix if it is repeated.
@@ -328,7 +328,7 @@ func (ms *messageSymbol) GenerateAlias(g *Generator, pkg string) {
 					ctyp = "(" + typ + ")"
 				}
 
-				g.P("func (this *", ms.sym, ") ", get.name, "() []", typ, " {")
+				g.P("func (m *", ms.sym, ") ", get.name, "() []", typ, " {")
 				g.In()
 				g.P("o := ", val)
 				g.P("if o == nil {")
@@ -351,7 +351,7 @@ func (ms *messageSymbol) GenerateAlias(g *Generator, pkg string) {
 			val = "(" + typ + ")(" + val + ")"
 		}
 
-		g.P("func (this *", ms.sym, ") ", get.name, "() ", typ, " { return ", val, " }")
+		g.P("func (m *", ms.sym, ") ", get.name, "() ", typ, " { return ", val, " }")
 	}
 }
 
@@ -1359,35 +1359,36 @@ func (g *Generator) generateMessage(message *Descriptor) {
 		usedNames[n] = true
 	}
 	fieldNames := make(map[*descriptor.FieldDescriptorProto]string)
+	fieldGetterNames := make(map[*descriptor.FieldDescriptorProto]string)
 	g.P("type ", ccTypeName, " struct {")
 	g.In()
 
 	for _, field := range message.Field {
-		fieldname := CamelCase(*field.Name)
-		for usedNames[fieldname] {
-			fieldname += "_"
+		fieldName := CamelCase(*field.Name)
+		for usedNames[fieldName] {
+			fieldName += "_"
 		}
-		usedNames[fieldname] = true
-		fieldNames[field] = fieldname
+		fieldGetterName := fieldName
+		usedNames[fieldName] = true
 		typename, wiretype := g.GoType(message, field)
 		jsonName := *field.Name
 		tag := fmt.Sprintf("protobuf:%s json:%q", g.goTag(field, wiretype), jsonName+",omitempty")
-		g.P(fieldname, "\t", typename, "\t`", tag, "`")
+		fieldNames[field] = fieldName
+		fieldGetterNames[field] = fieldGetterName
+		g.P(fieldName, "\t", typename, "\t`", tag, "`")
 		g.RecordTypeUse(field.GetTypeName())
 	}
 	if len(message.ExtensionRange) > 0 {
 		g.P("XXX_extensions\t\tmap[int32]", g.Pkg["proto"], ".Extension `json:\"-\"`")
 	}
-	if !message.group {
-		g.P("XXX_unrecognized\t[]byte `json:\"-\"`")
-	}
+	g.P("XXX_unrecognized\t[]byte `json:\"-\"`")
 	g.Out()
 	g.P("}")
 
 	// Reset, String and ProtoMessage methods.
-	g.P("func (this *", ccTypeName, ") Reset() { *this = ", ccTypeName, "{} }")
+	g.P("func (m *", ccTypeName, ") Reset() { *m = ", ccTypeName, "{} }")
 	if !message.group {
-		g.P("func (this *", ccTypeName, ") String() string { return ", g.Pkg["proto"], ".CompactTextString(this) }")
+		g.P("func (m *", ccTypeName, ") String() string { return ", g.Pkg["proto"], ".CompactTextString(m) }")
 		g.P("func (*", ccTypeName, ") ProtoMessage() {}")
 	}
 
@@ -1399,14 +1400,14 @@ func (g *Generator) generateMessage(message *Descriptor) {
 		if opts := message.Options; opts != nil && opts.GetMessageSetWireFormat() {
 			isMessageSet = true
 			g.P()
-			g.P("func (this *", ccTypeName, ") Marshal() ([]byte, error) {")
+			g.P("func (m *", ccTypeName, ") Marshal() ([]byte, error) {")
 			g.In()
-			g.P("return ", g.Pkg["proto"], ".MarshalMessageSet(this.ExtensionMap())")
+			g.P("return ", g.Pkg["proto"], ".MarshalMessageSet(m.ExtensionMap())")
 			g.Out()
 			g.P("}")
-			g.P("func (this *", ccTypeName, ") Unmarshal(buf []byte) error {")
+			g.P("func (m *", ccTypeName, ") Unmarshal(buf []byte) error {")
 			g.In()
-			g.P("return ", g.Pkg["proto"], ".UnmarshalMessageSet(buf, this.ExtensionMap())")
+			g.P("return ", g.Pkg["proto"], ".UnmarshalMessageSet(buf, m.ExtensionMap())")
 			g.Out()
 			g.P("}")
 			g.P("// ensure ", ccTypeName, " satisfies proto.Marshaler and proto.Unmarshaler")
@@ -1428,14 +1429,14 @@ func (g *Generator) generateMessage(message *Descriptor) {
 		g.P("return extRange_", ccTypeName)
 		g.Out()
 		g.P("}")
-		g.P("func (this *", ccTypeName, ") ExtensionMap() map[int32]", g.Pkg["proto"], ".Extension {")
+		g.P("func (m *", ccTypeName, ") ExtensionMap() map[int32]", g.Pkg["proto"], ".Extension {")
 		g.In()
-		g.P("if this.XXX_extensions == nil {")
+		g.P("if m.XXX_extensions == nil {")
 		g.In()
-		g.P("this.XXX_extensions = make(map[int32]", g.Pkg["proto"], ".Extension)")
+		g.P("m.XXX_extensions = make(map[int32]", g.Pkg["proto"], ".Extension)")
 		g.Out()
 		g.P("}")
-		g.P("return this.XXX_extensions")
+		g.P("return m.XXX_extensions")
 		g.Out()
 		g.P("}")
 	}
@@ -1495,7 +1496,7 @@ func (g *Generator) generateMessage(message *Descriptor) {
 	for _, field := range message.Field {
 		fname := fieldNames[field]
 		typename, _ := g.GoType(message, field)
-		mname := "Get" + fname
+		mname := "Get" + fieldGetterNames[field]
 		star := ""
 		if needsStar(*field.Type) && typename[0] == '*' {
 			typename = typename[1:]
@@ -1532,7 +1533,7 @@ func (g *Generator) generateMessage(message *Descriptor) {
 			})
 		}
 
-		g.P("func (this *", ccTypeName, ") "+mname+"() "+typename+" {")
+		g.P("func (m *", ccTypeName, ") "+mname+"() "+typename+" {")
 		g.In()
 		def, hasDef := defNames[field]
 		typeDefaultIsNil := false // whether this field type's default value is a literal nil unless specified
@@ -1548,9 +1549,9 @@ func (g *Generator) generateMessage(message *Descriptor) {
 		if typeDefaultIsNil {
 			// A bytes field with no explicit default needs less generated code,
 			// as does a message or group field, or a repeated field.
-			g.P("if this != nil {")
+			g.P("if m != nil {")
 			g.In()
-			g.P("return this." + fname)
+			g.P("return m." + fname)
 			g.Out()
 			g.P("}")
 			g.P("return nil")
@@ -1559,9 +1560,9 @@ func (g *Generator) generateMessage(message *Descriptor) {
 			g.P()
 			continue
 		}
-		g.P("if this != nil && this." + fname + " != nil {")
+		g.P("if m != nil && m." + fname + " != nil {")
 		g.In()
-		g.P("return " + star + "this." + fname)
+		g.P("return " + star + "m." + fname)
 		g.Out()
 		g.P("}")
 		if hasDef {

+ 45 - 24
protoc-gen-go/plugin/plugin.pb.go

@@ -21,34 +21,55 @@ type CodeGeneratorRequest struct {
 	XXX_unrecognized []byte                                 `json:"-"`
 }
 
-func (this *CodeGeneratorRequest) Reset()         { *this = CodeGeneratorRequest{} }
-func (this *CodeGeneratorRequest) String() string { return proto.CompactTextString(this) }
-func (*CodeGeneratorRequest) ProtoMessage()       {}
+func (m *CodeGeneratorRequest) Reset()         { *m = CodeGeneratorRequest{} }
+func (m *CodeGeneratorRequest) String() string { return proto.CompactTextString(m) }
+func (*CodeGeneratorRequest) ProtoMessage()    {}
 
-func (this *CodeGeneratorRequest) GetParameter() string {
-	if this != nil && this.Parameter != nil {
-		return *this.Parameter
+func (m *CodeGeneratorRequest) GetFileToGenerate() []string {
+	if m != nil {
+		return m.FileToGenerate
+	}
+	return nil
+}
+
+func (m *CodeGeneratorRequest) GetParameter() string {
+	if m != nil && m.Parameter != nil {
+		return *m.Parameter
 	}
 	return ""
 }
 
+func (m *CodeGeneratorRequest) GetProtoFile() []*google_protobuf.FileDescriptorProto {
+	if m != nil {
+		return m.ProtoFile
+	}
+	return nil
+}
+
 type CodeGeneratorResponse struct {
 	Error            *string                       `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"`
 	File             []*CodeGeneratorResponse_File `protobuf:"bytes,15,rep,name=file" json:"file,omitempty"`
 	XXX_unrecognized []byte                        `json:"-"`
 }
 
-func (this *CodeGeneratorResponse) Reset()         { *this = CodeGeneratorResponse{} }
-func (this *CodeGeneratorResponse) String() string { return proto.CompactTextString(this) }
-func (*CodeGeneratorResponse) ProtoMessage()       {}
+func (m *CodeGeneratorResponse) Reset()         { *m = CodeGeneratorResponse{} }
+func (m *CodeGeneratorResponse) String() string { return proto.CompactTextString(m) }
+func (*CodeGeneratorResponse) ProtoMessage()    {}
 
-func (this *CodeGeneratorResponse) GetError() string {
-	if this != nil && this.Error != nil {
-		return *this.Error
+func (m *CodeGeneratorResponse) GetError() string {
+	if m != nil && m.Error != nil {
+		return *m.Error
 	}
 	return ""
 }
 
+func (m *CodeGeneratorResponse) GetFile() []*CodeGeneratorResponse_File {
+	if m != nil {
+		return m.File
+	}
+	return nil
+}
+
 type CodeGeneratorResponse_File struct {
 	Name             *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
 	InsertionPoint   *string `protobuf:"bytes,2,opt,name=insertion_point" json:"insertion_point,omitempty"`
@@ -56,27 +77,27 @@ type CodeGeneratorResponse_File struct {
 	XXX_unrecognized []byte  `json:"-"`
 }
 
-func (this *CodeGeneratorResponse_File) Reset()         { *this = CodeGeneratorResponse_File{} }
-func (this *CodeGeneratorResponse_File) String() string { return proto.CompactTextString(this) }
-func (*CodeGeneratorResponse_File) ProtoMessage()       {}
+func (m *CodeGeneratorResponse_File) Reset()         { *m = CodeGeneratorResponse_File{} }
+func (m *CodeGeneratorResponse_File) String() string { return proto.CompactTextString(m) }
+func (*CodeGeneratorResponse_File) ProtoMessage()    {}
 
-func (this *CodeGeneratorResponse_File) GetName() string {
-	if this != nil && this.Name != nil {
-		return *this.Name
+func (m *CodeGeneratorResponse_File) GetName() string {
+	if m != nil && m.Name != nil {
+		return *m.Name
 	}
 	return ""
 }
 
-func (this *CodeGeneratorResponse_File) GetInsertionPoint() string {
-	if this != nil && this.InsertionPoint != nil {
-		return *this.InsertionPoint
+func (m *CodeGeneratorResponse_File) GetInsertionPoint() string {
+	if m != nil && m.InsertionPoint != nil {
+		return *m.InsertionPoint
 	}
 	return ""
 }
 
-func (this *CodeGeneratorResponse_File) GetContent() string {
-	if this != nil && this.Content != nil {
-		return *this.Content
+func (m *CodeGeneratorResponse_File) GetContent() string {
+	if m != nil && m.Content != nil {
+		return *m.Content
 	}
 	return ""
 }

+ 66 - 65
protoc-gen-go/testdata/my_test/test.pb.go

@@ -175,65 +175,66 @@ type Request struct {
 	XXX_unrecognized []byte             `json:"-"`
 }
 
-func (this *Request) Reset()         { *this = Request{} }
-func (this *Request) String() string { return proto.CompactTextString(this) }
-func (*Request) ProtoMessage()       {}
+func (m *Request) Reset()         { *m = Request{} }
+func (m *Request) String() string { return proto.CompactTextString(m) }
+func (*Request) ProtoMessage()    {}
 
 const Default_Request_Hat HatType = HatType_FEDORA
 
 var Default_Request_Deadline float32 = float32(math.Inf(1))
 
-func (this *Request) GetKey() []int64 {
-	if this != nil {
-		return this.Key
+func (m *Request) GetKey() []int64 {
+	if m != nil {
+		return m.Key
 	}
 	return nil
 }
 
-func (this *Request) GetHue() Request_Color {
-	if this != nil && this.Hue != nil {
-		return *this.Hue
+func (m *Request) GetHue() Request_Color {
+	if m != nil && m.Hue != nil {
+		return *m.Hue
 	}
 	return 0
 }
 
-func (this *Request) GetHat() HatType {
-	if this != nil && this.Hat != nil {
-		return *this.Hat
+func (m *Request) GetHat() HatType {
+	if m != nil && m.Hat != nil {
+		return *m.Hat
 	}
 	return Default_Request_Hat
 }
 
-func (this *Request) GetDeadline() float32 {
-	if this != nil && this.Deadline != nil {
-		return *this.Deadline
+func (m *Request) GetDeadline() float32 {
+	if m != nil && m.Deadline != nil {
+		return *m.Deadline
 	}
 	return Default_Request_Deadline
 }
 
-func (this *Request) GetSomegroup() *Request_SomeGroup {
-	if this != nil {
-		return this.Somegroup
+func (m *Request) GetSomegroup() *Request_SomeGroup {
+	if m != nil {
+		return m.Somegroup
 	}
 	return nil
 }
 
-func (this *Request) GetReset_() int32 {
-	if this != nil && this.Reset_ != nil {
-		return *this.Reset_
+func (m *Request) GetReset_() int32 {
+	if m != nil && m.Reset_ != nil {
+		return *m.Reset_
 	}
 	return 0
 }
 
 type Request_SomeGroup struct {
-	GroupField *int32 `protobuf:"varint,9,opt,name=group_field" json:"group_field,omitempty"`
+	GroupField       *int32 `protobuf:"varint,9,opt,name=group_field" json:"group_field,omitempty"`
+	XXX_unrecognized []byte `json:"-"`
 }
 
-func (this *Request_SomeGroup) Reset() { *this = Request_SomeGroup{} }
+func (m *Request_SomeGroup) Reset() { *m = Request_SomeGroup{} }
 
-func (this *Request_SomeGroup) GetGroupField() int32 {
-	if this != nil && this.GroupField != nil {
-		return *this.GroupField
+func (m *Request_SomeGroup) GetGroupField() int32 {
+	if m != nil && m.GroupField != nil {
+		return *m.GroupField
 	}
 	return 0
 }
@@ -245,9 +246,9 @@ type Reply struct {
 	XXX_unrecognized []byte                    `json:"-"`
 }
 
-func (this *Reply) Reset()         { *this = Reply{} }
-func (this *Reply) String() string { return proto.CompactTextString(this) }
-func (*Reply) ProtoMessage()       {}
+func (m *Reply) Reset()         { *m = Reply{} }
+func (m *Reply) String() string { return proto.CompactTextString(m) }
+func (*Reply) ProtoMessage()    {}
 
 var extRange_Reply = []proto.ExtensionRange{
 	{100, 536870911},
@@ -256,23 +257,23 @@ var extRange_Reply = []proto.ExtensionRange{
 func (*Reply) ExtensionRangeArray() []proto.ExtensionRange {
 	return extRange_Reply
 }
-func (this *Reply) ExtensionMap() map[int32]proto.Extension {
-	if this.XXX_extensions == nil {
-		this.XXX_extensions = make(map[int32]proto.Extension)
+func (m *Reply) ExtensionMap() map[int32]proto.Extension {
+	if m.XXX_extensions == nil {
+		m.XXX_extensions = make(map[int32]proto.Extension)
 	}
-	return this.XXX_extensions
+	return m.XXX_extensions
 }
 
-func (this *Reply) GetFound() []*Reply_Entry {
-	if this != nil {
-		return this.Found
+func (m *Reply) GetFound() []*Reply_Entry {
+	if m != nil {
+		return m.Found
 	}
 	return nil
 }
 
-func (this *Reply) GetCompactKeys() []int32 {
-	if this != nil {
-		return this.CompactKeys
+func (m *Reply) GetCompactKeys() []int32 {
+	if m != nil {
+		return m.CompactKeys
 	}
 	return nil
 }
@@ -284,29 +285,29 @@ type Reply_Entry struct {
 	XXX_unrecognized              []byte `json:"-"`
 }
 
-func (this *Reply_Entry) Reset()         { *this = Reply_Entry{} }
-func (this *Reply_Entry) String() string { return proto.CompactTextString(this) }
-func (*Reply_Entry) ProtoMessage()       {}
+func (m *Reply_Entry) Reset()         { *m = Reply_Entry{} }
+func (m *Reply_Entry) String() string { return proto.CompactTextString(m) }
+func (*Reply_Entry) ProtoMessage()    {}
 
 const Default_Reply_Entry_Value int64 = 7
 
-func (this *Reply_Entry) GetKeyThatNeeds_1234Camel_CasIng() int64 {
-	if this != nil && this.KeyThatNeeds_1234Camel_CasIng != nil {
-		return *this.KeyThatNeeds_1234Camel_CasIng
+func (m *Reply_Entry) GetKeyThatNeeds_1234Camel_CasIng() int64 {
+	if m != nil && m.KeyThatNeeds_1234Camel_CasIng != nil {
+		return *m.KeyThatNeeds_1234Camel_CasIng
 	}
 	return 0
 }
 
-func (this *Reply_Entry) GetValue() int64 {
-	if this != nil && this.Value != nil {
-		return *this.Value
+func (m *Reply_Entry) GetValue() int64 {
+	if m != nil && m.Value != nil {
+		return *m.Value
 	}
 	return Default_Reply_Entry_Value
 }
 
-func (this *Reply_Entry) GetXMyFieldName_2() int64 {
-	if this != nil && this.XMyFieldName_2 != nil {
-		return *this.XMyFieldName_2
+func (m *Reply_Entry) GetXMyFieldName_2() int64 {
+	if m != nil && m.XMyFieldName_2 != nil {
+		return *m.XMyFieldName_2
 	}
 	return 0
 }
@@ -315,9 +316,9 @@ type ReplyExtensions struct {
 	XXX_unrecognized []byte `json:"-"`
 }
 
-func (this *ReplyExtensions) Reset()         { *this = ReplyExtensions{} }
-func (this *ReplyExtensions) String() string { return proto.CompactTextString(this) }
-func (*ReplyExtensions) ProtoMessage()       {}
+func (m *ReplyExtensions) Reset()         { *m = ReplyExtensions{} }
+func (m *ReplyExtensions) String() string { return proto.CompactTextString(m) }
+func (*ReplyExtensions) ProtoMessage()    {}
 
 var E_ReplyExtensions_Time = &proto.ExtensionDesc{
 	ExtendedType:  (*Reply)(nil),
@@ -332,15 +333,15 @@ type OldReply struct {
 	XXX_unrecognized []byte                    `json:"-"`
 }
 
-func (this *OldReply) Reset()         { *this = OldReply{} }
-func (this *OldReply) String() string { return proto.CompactTextString(this) }
-func (*OldReply) ProtoMessage()       {}
+func (m *OldReply) Reset()         { *m = OldReply{} }
+func (m *OldReply) String() string { return proto.CompactTextString(m) }
+func (*OldReply) ProtoMessage()    {}
 
-func (this *OldReply) Marshal() ([]byte, error) {
-	return proto.MarshalMessageSet(this.ExtensionMap())
+func (m *OldReply) Marshal() ([]byte, error) {
+	return proto.MarshalMessageSet(m.ExtensionMap())
 }
-func (this *OldReply) Unmarshal(buf []byte) error {
-	return proto.UnmarshalMessageSet(buf, this.ExtensionMap())
+func (m *OldReply) Unmarshal(buf []byte) error {
+	return proto.UnmarshalMessageSet(buf, m.ExtensionMap())
 }
 
 // ensure OldReply satisfies proto.Marshaler and proto.Unmarshaler
@@ -354,11 +355,11 @@ var extRange_OldReply = []proto.ExtensionRange{
 func (*OldReply) ExtensionRangeArray() []proto.ExtensionRange {
 	return extRange_OldReply
 }
-func (this *OldReply) ExtensionMap() map[int32]proto.Extension {
-	if this.XXX_extensions == nil {
-		this.XXX_extensions = make(map[int32]proto.Extension)
+func (m *OldReply) ExtensionMap() map[int32]proto.Extension {
+	if m.XXX_extensions == nil {
+		m.XXX_extensions = make(map[int32]proto.Extension)
 	}
-	return this.XXX_extensions
+	return m.XXX_extensions
 }
 
 var E_Tag = &proto.ExtensionDesc{

+ 66 - 65
protoc-gen-go/testdata/my_test/test.pb.go.golden

@@ -175,65 +175,66 @@ type Request struct {
 	XXX_unrecognized []byte             `json:"-"`
 }
 
-func (this *Request) Reset()         { *this = Request{} }
-func (this *Request) String() string { return proto.CompactTextString(this) }
-func (*Request) ProtoMessage()       {}
+func (m *Request) Reset()         { *m = Request{} }
+func (m *Request) String() string { return proto.CompactTextString(m) }
+func (*Request) ProtoMessage()    {}
 
 const Default_Request_Hat HatType = HatType_FEDORA
 
 var Default_Request_Deadline float32 = float32(math.Inf(1))
 
-func (this *Request) GetKey() []int64 {
-	if this != nil {
-		return this.Key
+func (m *Request) GetKey() []int64 {
+	if m != nil {
+		return m.Key
 	}
 	return nil
 }
 
-func (this *Request) GetHue() Request_Color {
-	if this != nil && this.Hue != nil {
-		return *this.Hue
+func (m *Request) GetHue() Request_Color {
+	if m != nil && m.Hue != nil {
+		return *m.Hue
 	}
 	return 0
 }
 
-func (this *Request) GetHat() HatType {
-	if this != nil && this.Hat != nil {
-		return *this.Hat
+func (m *Request) GetHat() HatType {
+	if m != nil && m.Hat != nil {
+		return *m.Hat
 	}
 	return Default_Request_Hat
 }
 
-func (this *Request) GetDeadline() float32 {
-	if this != nil && this.Deadline != nil {
-		return *this.Deadline
+func (m *Request) GetDeadline() float32 {
+	if m != nil && m.Deadline != nil {
+		return *m.Deadline
 	}
 	return Default_Request_Deadline
 }
 
-func (this *Request) GetSomegroup() *Request_SomeGroup {
-	if this != nil {
-		return this.Somegroup
+func (m *Request) GetSomegroup() *Request_SomeGroup {
+	if m != nil {
+		return m.Somegroup
 	}
 	return nil
 }
 
-func (this *Request) GetReset_() int32 {
-	if this != nil && this.Reset_ != nil {
-		return *this.Reset_
+func (m *Request) GetReset_() int32 {
+	if m != nil && m.Reset_ != nil {
+		return *m.Reset_
 	}
 	return 0
 }
 
 type Request_SomeGroup struct {
-	GroupField *int32 `protobuf:"varint,9,opt,name=group_field" json:"group_field,omitempty"`
+	GroupField       *int32 `protobuf:"varint,9,opt,name=group_field" json:"group_field,omitempty"`
+	XXX_unrecognized []byte `json:"-"`
 }
 
-func (this *Request_SomeGroup) Reset() { *this = Request_SomeGroup{} }
+func (m *Request_SomeGroup) Reset() { *m = Request_SomeGroup{} }
 
-func (this *Request_SomeGroup) GetGroupField() int32 {
-	if this != nil && this.GroupField != nil {
-		return *this.GroupField
+func (m *Request_SomeGroup) GetGroupField() int32 {
+	if m != nil && m.GroupField != nil {
+		return *m.GroupField
 	}
 	return 0
 }
@@ -245,9 +246,9 @@ type Reply struct {
 	XXX_unrecognized []byte                    `json:"-"`
 }
 
-func (this *Reply) Reset()         { *this = Reply{} }
-func (this *Reply) String() string { return proto.CompactTextString(this) }
-func (*Reply) ProtoMessage()       {}
+func (m *Reply) Reset()         { *m = Reply{} }
+func (m *Reply) String() string { return proto.CompactTextString(m) }
+func (*Reply) ProtoMessage()    {}
 
 var extRange_Reply = []proto.ExtensionRange{
 	{100, 536870911},
@@ -256,23 +257,23 @@ var extRange_Reply = []proto.ExtensionRange{
 func (*Reply) ExtensionRangeArray() []proto.ExtensionRange {
 	return extRange_Reply
 }
-func (this *Reply) ExtensionMap() map[int32]proto.Extension {
-	if this.XXX_extensions == nil {
-		this.XXX_extensions = make(map[int32]proto.Extension)
+func (m *Reply) ExtensionMap() map[int32]proto.Extension {
+	if m.XXX_extensions == nil {
+		m.XXX_extensions = make(map[int32]proto.Extension)
 	}
-	return this.XXX_extensions
+	return m.XXX_extensions
 }
 
-func (this *Reply) GetFound() []*Reply_Entry {
-	if this != nil {
-		return this.Found
+func (m *Reply) GetFound() []*Reply_Entry {
+	if m != nil {
+		return m.Found
 	}
 	return nil
 }
 
-func (this *Reply) GetCompactKeys() []int32 {
-	if this != nil {
-		return this.CompactKeys
+func (m *Reply) GetCompactKeys() []int32 {
+	if m != nil {
+		return m.CompactKeys
 	}
 	return nil
 }
@@ -284,29 +285,29 @@ type Reply_Entry struct {
 	XXX_unrecognized              []byte `json:"-"`
 }
 
-func (this *Reply_Entry) Reset()         { *this = Reply_Entry{} }
-func (this *Reply_Entry) String() string { return proto.CompactTextString(this) }
-func (*Reply_Entry) ProtoMessage()       {}
+func (m *Reply_Entry) Reset()         { *m = Reply_Entry{} }
+func (m *Reply_Entry) String() string { return proto.CompactTextString(m) }
+func (*Reply_Entry) ProtoMessage()    {}
 
 const Default_Reply_Entry_Value int64 = 7
 
-func (this *Reply_Entry) GetKeyThatNeeds_1234Camel_CasIng() int64 {
-	if this != nil && this.KeyThatNeeds_1234Camel_CasIng != nil {
-		return *this.KeyThatNeeds_1234Camel_CasIng
+func (m *Reply_Entry) GetKeyThatNeeds_1234Camel_CasIng() int64 {
+	if m != nil && m.KeyThatNeeds_1234Camel_CasIng != nil {
+		return *m.KeyThatNeeds_1234Camel_CasIng
 	}
 	return 0
 }
 
-func (this *Reply_Entry) GetValue() int64 {
-	if this != nil && this.Value != nil {
-		return *this.Value
+func (m *Reply_Entry) GetValue() int64 {
+	if m != nil && m.Value != nil {
+		return *m.Value
 	}
 	return Default_Reply_Entry_Value
 }
 
-func (this *Reply_Entry) GetXMyFieldName_2() int64 {
-	if this != nil && this.XMyFieldName_2 != nil {
-		return *this.XMyFieldName_2
+func (m *Reply_Entry) GetXMyFieldName_2() int64 {
+	if m != nil && m.XMyFieldName_2 != nil {
+		return *m.XMyFieldName_2
 	}
 	return 0
 }
@@ -315,9 +316,9 @@ type ReplyExtensions struct {
 	XXX_unrecognized []byte `json:"-"`
 }
 
-func (this *ReplyExtensions) Reset()         { *this = ReplyExtensions{} }
-func (this *ReplyExtensions) String() string { return proto.CompactTextString(this) }
-func (*ReplyExtensions) ProtoMessage()       {}
+func (m *ReplyExtensions) Reset()         { *m = ReplyExtensions{} }
+func (m *ReplyExtensions) String() string { return proto.CompactTextString(m) }
+func (*ReplyExtensions) ProtoMessage()    {}
 
 var E_ReplyExtensions_Time = &proto.ExtensionDesc{
 	ExtendedType:  (*Reply)(nil),
@@ -332,15 +333,15 @@ type OldReply struct {
 	XXX_unrecognized []byte                    `json:"-"`
 }
 
-func (this *OldReply) Reset()         { *this = OldReply{} }
-func (this *OldReply) String() string { return proto.CompactTextString(this) }
-func (*OldReply) ProtoMessage()       {}
+func (m *OldReply) Reset()         { *m = OldReply{} }
+func (m *OldReply) String() string { return proto.CompactTextString(m) }
+func (*OldReply) ProtoMessage()    {}
 
-func (this *OldReply) Marshal() ([]byte, error) {
-	return proto.MarshalMessageSet(this.ExtensionMap())
+func (m *OldReply) Marshal() ([]byte, error) {
+	return proto.MarshalMessageSet(m.ExtensionMap())
 }
-func (this *OldReply) Unmarshal(buf []byte) error {
-	return proto.UnmarshalMessageSet(buf, this.ExtensionMap())
+func (m *OldReply) Unmarshal(buf []byte) error {
+	return proto.UnmarshalMessageSet(buf, m.ExtensionMap())
 }
 
 // ensure OldReply satisfies proto.Marshaler and proto.Unmarshaler
@@ -354,11 +355,11 @@ var extRange_OldReply = []proto.ExtensionRange{
 func (*OldReply) ExtensionRangeArray() []proto.ExtensionRange {
 	return extRange_OldReply
 }
-func (this *OldReply) ExtensionMap() map[int32]proto.Extension {
-	if this.XXX_extensions == nil {
-		this.XXX_extensions = make(map[int32]proto.Extension)
+func (m *OldReply) ExtensionMap() map[int32]proto.Extension {
+	if m.XXX_extensions == nil {
+		m.XXX_extensions = make(map[int32]proto.Extension)
 	}
-	return this.XXX_extensions
+	return m.XXX_extensions
 }
 
 var E_Tag = &proto.ExtensionDesc{

Some files were not shown because too many files changed in this diff