Просмотр исходного кода

cmd/protoc-gen-go: fix init order for v1 registration

The v1 registration leaks the message types out to the proto package.
When doing that, it must ensure that the reflection data structures
for those types are properly initialized first. We achieve that by
doing v1 registration at the end of the reflection init function.

Change-Id: If6df18df59d05bad50ff39c2eff6beb19e7466cc
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168348
Reviewed-by: Damien Neil <dneil@google.com>
Joe Tsai 6 лет назад
Родитель
Сommit
559d47f1da
56 измененных файлов с 405 добавлено и 576 удалено
  1. 1 4
      cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
  2. 3 6
      cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
  3. 3 7
      cmd/protoc-gen-go/internal_gengo/main.go
  4. 2 0
      cmd/protoc-gen-go/internal_gengo/reflect.go
  5. 3 6
      cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
  6. 7 10
      cmd/protoc-gen-go/testdata/comments/comments.pb.go
  7. 3 6
      cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
  8. 3 6
      cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
  9. 54 58
      cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
  10. 2 5
      cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
  11. 37 41
      cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
  12. 3 6
      cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
  13. 2 5
      cmd/protoc-gen-go/testdata/import_public/a.pb.go
  14. 2 5
      cmd/protoc-gen-go/testdata/import_public/b.pb.go
  15. 7 11
      cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
  16. 2 5
      cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
  17. 2 5
      cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
  18. 2 5
      cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
  19. 4 7
      cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
  20. 2 5
      cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
  21. 2 5
      cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
  22. 2 5
      cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
  23. 2 5
      cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
  24. 2 5
      cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
  25. 2 5
      cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
  26. 2 5
      cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
  27. 2 5
      cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
  28. 2 5
      cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
  29. 3 6
      cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
  30. 9 12
      cmd/protoc-gen-go/testdata/proto2/enum.pb.go
  31. 11 14
      cmd/protoc-gen-go/testdata/proto2/fields.pb.go
  32. 4 7
      cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
  33. 2 5
      cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
  34. 2 5
      cmd/protoc-gen-go/testdata/proto3/enum.pb.go
  35. 7 10
      cmd/protoc-gen-go/testdata/proto3/fields.pb.go
  36. 42 46
      encoding/testprotos/pb2/test.pb.go
  37. 15 18
      encoding/testprotos/pb3/test.pb.go
  38. 7 10
      internal/testprotos/conformance/conformance.pb.go
  39. 2 5
      internal/testprotos/legacy/legacy.pb.go
  40. 2 6
      internal/testprotos/test/ext.pb.go
  41. 72 76
      internal/testprotos/test/test.pb.go
  42. 3 6
      internal/testprotos/test/test_import.pb.go
  43. 2 5
      internal/testprotos/test/test_public.pb.go
  44. 2 5
      internal/testprotos/test/test_weak.pb.go
  45. 14 18
      reflect/protoregistry/testprotos/test.pb.go
  46. 2 5
      types/known/any.pb.go
  47. 4 7
      types/known/api.pb.go
  48. 2 5
      types/known/duration.pb.go
  49. 2 5
      types/known/empty.pb.go
  50. 2 5
      types/known/field_mask.pb.go
  51. 2 5
      types/known/source_context.pb.go
  52. 6 9
      types/known/struct.pb.go
  53. 2 5
      types/known/timestamp.pb.go
  54. 9 12
      types/known/type.pb.go
  55. 10 13
      types/known/wrappers.pb.go
  56. 5 8
      types/plugin/plugin.pb.go

+ 1 - 4
cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go

@@ -9,10 +9,6 @@ import (
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 )
 
-func init() {
-	proto.RegisterFile("grpc/deprecation.proto", xxx_File_grpc_deprecation_proto_rawdesc_gzipped)
-}
-
 var xxx_File_grpc_deprecation_proto_rawdesc = []byte{
 	// 245 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x16, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69,
@@ -59,6 +55,7 @@ func xxx_File_grpc_deprecation_proto_init() {
 		GoTypes:           xxx_File_grpc_deprecation_proto_goTypes,
 		DependencyIndexes: xxx_File_grpc_deprecation_proto_depIdxs,
 	}.Init()
+	proto.RegisterFile("grpc/deprecation.proto", xxx_File_grpc_deprecation_proto_rawdesc_gzipped)
 	xxx_File_grpc_deprecation_proto_goTypes = nil
 	xxx_File_grpc_deprecation_proto_depIdxs = nil
 }

+ 3 - 6
cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go

@@ -82,12 +82,6 @@ func (m *Response) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_Response proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("grpc/grpc.proto", xxx_File_grpc_grpc_proto_rawdesc_gzipped)
-	proto.RegisterType((*Request)(nil), "goproto.protoc.grpc.Request")
-	proto.RegisterType((*Response)(nil), "goproto.protoc.grpc.Response")
-}
-
 var xxx_File_grpc_grpc_proto_rawdesc = []byte{
 	// 466 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x0f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74,
@@ -161,6 +155,9 @@ func xxx_File_grpc_grpc_proto_init() {
 		xxx_File_grpc_grpc_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_grpc_grpc_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("grpc/grpc.proto", xxx_File_grpc_grpc_proto_rawdesc_gzipped)
+	proto.RegisterType((*Request)(nil), "goproto.protoc.grpc.Request")
+	proto.RegisterType((*Response)(nil), "goproto.protoc.grpc.Response")
 	xxx_File_grpc_grpc_proto_goTypes = nil
 	xxx_File_grpc_grpc_proto_depIdxs = nil
 }

+ 3 - 7
cmd/protoc-gen-go/internal_gengo/main.go

@@ -132,7 +132,6 @@ func GenerateFile(gen *protogen.Plugin, file *protogen.File) *protogen.Generated
 	}
 	genExtensions(gen, g, f)
 
-	genInitFunction(gen, g, f)
 	genFileDescriptor(gen, g, f)
 	genReflectFileDescriptor(gen, g, f)
 
@@ -775,15 +774,14 @@ func extensionVar(f *protogen.File, extension *protogen.Extension) protogen.GoId
 	return f.GoImportPath.Ident(name)
 }
 
-// genInitFunction generates an init function that registers the types in the
-// generated file with the proto package.
-func genInitFunction(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo) {
+// genRegistrationV1 generates the init function body that registers the
+// types in the generated file with the v1 proto package.
+func genRegistrationV1(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo) {
 	// TODO: Remove this function when we always register with v2.
 	if isDescriptor(f.File) {
 		return
 	}
 
-	g.P("func init() {")
 	g.P(protoPackage.Ident("RegisterFile"), "(", strconv.Quote(f.Desc.Path()), ", ", f.descriptorGzipVar, ")")
 	for _, enum := range f.allEnums {
 		name := enum.GoIdent.GoName
@@ -818,8 +816,6 @@ func genInitFunction(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInf
 	for _, extension := range f.allExtensions {
 		g.P(protoPackage.Ident("RegisterExtension"), "(", extensionVar(f.File, extension), ")")
 	}
-	g.P("}")
-	g.P()
 }
 
 // deprecationComment returns a standard deprecation comment if deprecated is true.

+ 2 - 0
cmd/protoc-gen-go/internal_gengo/reflect.go

@@ -207,6 +207,8 @@ func genReflectFileDescriptor(gen *protogen.Plugin, g *protogen.GeneratedFile, f
 		}
 	}
 
+	genRegistrationV1(gen, g, f)
+
 	g.P(goTypesVarName(f), " = nil") // allow GC to reclaim resource
 	g.P(depIdxsVarName(f), " = nil") // allow GC to reclaim resource
 	g.P("}")

+ 3 - 6
cmd/protoc-gen-go/testdata/annotations/annotations.pb.go

@@ -100,12 +100,6 @@ func (m *AnnotationsTestMessage) GetAnnotationsTestField() string {
 	return ""
 }
 
-func init() {
-	proto.RegisterFile("annotations/annotations.proto", xxx_File_annotations_annotations_proto_rawdesc_gzipped)
-	proto.RegisterEnum("goproto.protoc.annotations.AnnotationsTestEnum", AnnotationsTestEnum_name, AnnotationsTestEnum_value)
-	proto.RegisterType((*AnnotationsTestMessage)(nil), "goproto.protoc.annotations.AnnotationsTestMessage")
-}
-
 var xxx_File_annotations_annotations_proto_rawdesc = []byte{
 	// 265 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1d, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e,
@@ -159,6 +153,9 @@ func xxx_File_annotations_annotations_proto_init() {
 		xxx_File_annotations_annotations_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_annotations_annotations_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("annotations/annotations.proto", xxx_File_annotations_annotations_proto_rawdesc_gzipped)
+	proto.RegisterEnum("goproto.protoc.annotations.AnnotationsTestEnum", AnnotationsTestEnum_name, AnnotationsTestEnum_value)
+	proto.RegisterType((*AnnotationsTestMessage)(nil), "goproto.protoc.annotations.AnnotationsTestMessage")
 	xxx_File_annotations_annotations_proto_goTypes = nil
 	xxx_File_annotations_annotations_proto_depIdxs = nil
 }

+ 7 - 10
cmd/protoc-gen-go/testdata/comments/comments.pb.go

@@ -280,16 +280,6 @@ func (m *Message2_Message2B) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_Message2_Message2B proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("comments/comments.proto", xxx_File_comments_comments_proto_rawdesc_gzipped)
-	proto.RegisterType((*Message1)(nil), "goproto.protoc.comments.Message1")
-	proto.RegisterType((*Message2)(nil), "goproto.protoc.comments.Message2")
-	proto.RegisterType((*Message1_Message1A)(nil), "goproto.protoc.comments.Message1.Message1A")
-	proto.RegisterType((*Message1_Message1B)(nil), "goproto.protoc.comments.Message1.Message1B")
-	proto.RegisterType((*Message2_Message2A)(nil), "goproto.protoc.comments.Message2.Message2A")
-	proto.RegisterType((*Message2_Message2B)(nil), "goproto.protoc.comments.Message2.Message2B")
-}
-
 var xxx_File_comments_comments_proto_rawdesc = []byte{
 	// 272 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x65,
@@ -345,6 +335,13 @@ func xxx_File_comments_comments_proto_init() {
 		xxx_File_comments_comments_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_comments_comments_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("comments/comments.proto", xxx_File_comments_comments_proto_rawdesc_gzipped)
+	proto.RegisterType((*Message1)(nil), "goproto.protoc.comments.Message1")
+	proto.RegisterType((*Message2)(nil), "goproto.protoc.comments.Message2")
+	proto.RegisterType((*Message1_Message1A)(nil), "goproto.protoc.comments.Message1.Message1A")
+	proto.RegisterType((*Message1_Message1B)(nil), "goproto.protoc.comments.Message1.Message1B")
+	proto.RegisterType((*Message2_Message2A)(nil), "goproto.protoc.comments.Message2.Message2A")
+	proto.RegisterType((*Message2_Message2B)(nil), "goproto.protoc.comments.Message2.Message2B")
 	xxx_File_comments_comments_proto_goTypes = nil
 	xxx_File_comments_comments_proto_depIdxs = nil
 }

+ 3 - 6
cmd/protoc-gen-go/testdata/comments/deprecated.pb.go

@@ -87,12 +87,6 @@ func (m *DeprecatedMessage) GetDeprecatedField() string {
 	return ""
 }
 
-func init() {
-	proto.RegisterFile("comments/deprecated.proto", xxx_File_comments_deprecated_proto_rawdesc_gzipped)
-	proto.RegisterEnum("goproto.protoc.comments.DeprecatedEnum", DeprecatedEnum_name, DeprecatedEnum_value)
-	proto.RegisterType((*DeprecatedMessage)(nil), "goproto.protoc.comments.DeprecatedMessage")
-}
-
 var xxx_File_comments_deprecated_proto_rawdesc = []byte{
 	// 246 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x64, 0x65, 0x70, 0x72, 0x65,
@@ -145,6 +139,9 @@ func xxx_File_comments_deprecated_proto_init() {
 		xxx_File_comments_deprecated_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_comments_deprecated_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("comments/deprecated.proto", xxx_File_comments_deprecated_proto_rawdesc_gzipped)
+	proto.RegisterEnum("goproto.protoc.comments.DeprecatedEnum", DeprecatedEnum_name, DeprecatedEnum_value)
+	proto.RegisterType((*DeprecatedMessage)(nil), "goproto.protoc.comments.DeprecatedMessage")
 	xxx_File_comments_deprecated_proto_goTypes = nil
 	xxx_File_comments_deprecated_proto_depIdxs = nil
 }

+ 3 - 6
cmd/protoc-gen-go/testdata/extensions/base/base.pb.go

@@ -111,12 +111,6 @@ func (m *MessageSetWireFormatMessage) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_MessageSetWireFormatMessage proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("extensions/base/base.proto", xxx_File_extensions_base_base_proto_rawdesc_gzipped)
-	proto.RegisterType((*BaseMessage)(nil), "goproto.protoc.extension.base.BaseMessage")
-	proto.RegisterType((*MessageSetWireFormatMessage)(nil), "goproto.protoc.extension.base.MessageSetWireFormatMessage")
-}
-
 var xxx_File_extensions_base_base_proto_rawdesc = []byte{
 	// 233 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x62, 0x61, 0x73,
@@ -166,6 +160,9 @@ func xxx_File_extensions_base_base_proto_init() {
 		xxx_File_extensions_base_base_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_extensions_base_base_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("extensions/base/base.proto", xxx_File_extensions_base_base_proto_rawdesc_gzipped)
+	proto.RegisterType((*BaseMessage)(nil), "goproto.protoc.extension.base.BaseMessage")
+	proto.RegisterType((*MessageSetWireFormatMessage)(nil), "goproto.protoc.extension.base.MessageSetWireFormatMessage")
 	xxx_File_extensions_base_base_proto_goTypes = nil
 	xxx_File_extensions_base_base_proto_depIdxs = nil
 }

+ 54 - 58
cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go

@@ -874,64 +874,6 @@ var (
 	// extend goproto.protoc.extension.base.MessageSetWireFormatMessage { optional goproto.protoc.extension.ext.MessageSetWireFormatExtension message_set_extension = 100; }
 	E_MessageSetWireFormatExtension_MessageSetExtension = &xxx_File_extensions_ext_ext_proto_extDescs[43]
 )
-
-func init() {
-	proto.RegisterFile("extensions/ext/ext.proto", xxx_File_extensions_ext_ext_proto_rawdesc_gzipped)
-	proto.RegisterEnum("goproto.protoc.extension.ext.Enum", Enum_name, Enum_value)
-	proto.RegisterType((*Message)(nil), "goproto.protoc.extension.ext.Message")
-	proto.RegisterType((*ExtensionGroup)(nil), "goproto.protoc.extension.ext.ExtensionGroup")
-	proto.RegisterType((*ExtendingMessage)(nil), "goproto.protoc.extension.ext.ExtendingMessage")
-	proto.RegisterType((*RepeatedGroup)(nil), "goproto.protoc.extension.ext.RepeatedGroup")
-	proto.RegisterType((*Extendable)(nil), "goproto.protoc.extension.ext.Extendable")
-	proto.RegisterType((*MessageSetWireFormatExtension)(nil), "goproto.protoc.extension.ext.MessageSetWireFormatExtension")
-	proto.RegisterType((*Message_M)(nil), "goproto.protoc.extension.ext.Message.M")
-	proto.RegisterType((*ExtendingMessage_ExtendingMessageSubmessage)(nil), "goproto.protoc.extension.ext.ExtendingMessage.ExtendingMessageSubmessage")
-	proto.RegisterExtension(E_ExtensionBool)
-	proto.RegisterExtension(E_ExtensionEnum)
-	proto.RegisterExtension(E_ExtensionInt32)
-	proto.RegisterExtension(E_ExtensionSint32)
-	proto.RegisterExtension(E_ExtensionUint32)
-	proto.RegisterExtension(E_ExtensionInt64)
-	proto.RegisterExtension(E_ExtensionSint64)
-	proto.RegisterExtension(E_ExtensionUint64)
-	proto.RegisterExtension(E_ExtensionSfixed32)
-	proto.RegisterExtension(E_ExtensionFixed32)
-	proto.RegisterExtension(E_ExtensionFloat)
-	proto.RegisterExtension(E_ExtensionSfixed64)
-	proto.RegisterExtension(E_ExtensionFixed64)
-	proto.RegisterExtension(E_ExtensionDouble)
-	proto.RegisterExtension(E_ExtensionString)
-	proto.RegisterExtension(E_ExtensionBytes)
-	proto.RegisterExtension(E_Extension_Message)
-	proto.RegisterExtension(E_Extension_MessageM)
-	proto.RegisterExtension(E_Extensiongroup)
-	proto.RegisterExtension(E_ExtraMessage)
-	proto.RegisterExtension(E_RepeatedXBool)
-	proto.RegisterExtension(E_RepeatedXEnum)
-	proto.RegisterExtension(E_RepeatedXInt32)
-	proto.RegisterExtension(E_RepeatedXSint32)
-	proto.RegisterExtension(E_RepeatedXUint32)
-	proto.RegisterExtension(E_RepeatedXInt64)
-	proto.RegisterExtension(E_RepeatedXSint64)
-	proto.RegisterExtension(E_RepeatedXUint64)
-	proto.RegisterExtension(E_RepeatedXSfixed32)
-	proto.RegisterExtension(E_RepeatedXFixed32)
-	proto.RegisterExtension(E_RepeatedXFloat)
-	proto.RegisterExtension(E_RepeatedXSfixed64)
-	proto.RegisterExtension(E_RepeatedXFixed64)
-	proto.RegisterExtension(E_RepeatedXDouble)
-	proto.RegisterExtension(E_RepeatedXString)
-	proto.RegisterExtension(E_RepeatedXBytes)
-	proto.RegisterExtension(E_RepeatedX_Message)
-	proto.RegisterExtension(E_Repeatedgroup)
-	proto.RegisterExtension(E_ExtendableField)
-	proto.RegisterExtension(E_ExtendableStringField)
-	proto.RegisterExtension(E_MessageSetExtension)
-	proto.RegisterExtension(E_ExtendingMessage_ExtendingMessageString)
-	proto.RegisterExtension(E_ExtendingMessage_ExtendingMessageSubmessage)
-	proto.RegisterExtension(E_MessageSetWireFormatExtension_MessageSetExtension)
-}
-
 var xxx_File_extensions_ext_ext_proto_rawdesc = []byte{
 	// 4996 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x18, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x65, 0x78, 0x74,
@@ -1351,6 +1293,60 @@ func xxx_File_extensions_ext_ext_proto_init() {
 		xxx_File_extensions_ext_ext_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_extensions_ext_ext_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("extensions/ext/ext.proto", xxx_File_extensions_ext_ext_proto_rawdesc_gzipped)
+	proto.RegisterEnum("goproto.protoc.extension.ext.Enum", Enum_name, Enum_value)
+	proto.RegisterType((*Message)(nil), "goproto.protoc.extension.ext.Message")
+	proto.RegisterType((*ExtensionGroup)(nil), "goproto.protoc.extension.ext.ExtensionGroup")
+	proto.RegisterType((*ExtendingMessage)(nil), "goproto.protoc.extension.ext.ExtendingMessage")
+	proto.RegisterType((*RepeatedGroup)(nil), "goproto.protoc.extension.ext.RepeatedGroup")
+	proto.RegisterType((*Extendable)(nil), "goproto.protoc.extension.ext.Extendable")
+	proto.RegisterType((*MessageSetWireFormatExtension)(nil), "goproto.protoc.extension.ext.MessageSetWireFormatExtension")
+	proto.RegisterType((*Message_M)(nil), "goproto.protoc.extension.ext.Message.M")
+	proto.RegisterType((*ExtendingMessage_ExtendingMessageSubmessage)(nil), "goproto.protoc.extension.ext.ExtendingMessage.ExtendingMessageSubmessage")
+	proto.RegisterExtension(E_ExtensionBool)
+	proto.RegisterExtension(E_ExtensionEnum)
+	proto.RegisterExtension(E_ExtensionInt32)
+	proto.RegisterExtension(E_ExtensionSint32)
+	proto.RegisterExtension(E_ExtensionUint32)
+	proto.RegisterExtension(E_ExtensionInt64)
+	proto.RegisterExtension(E_ExtensionSint64)
+	proto.RegisterExtension(E_ExtensionUint64)
+	proto.RegisterExtension(E_ExtensionSfixed32)
+	proto.RegisterExtension(E_ExtensionFixed32)
+	proto.RegisterExtension(E_ExtensionFloat)
+	proto.RegisterExtension(E_ExtensionSfixed64)
+	proto.RegisterExtension(E_ExtensionFixed64)
+	proto.RegisterExtension(E_ExtensionDouble)
+	proto.RegisterExtension(E_ExtensionString)
+	proto.RegisterExtension(E_ExtensionBytes)
+	proto.RegisterExtension(E_Extension_Message)
+	proto.RegisterExtension(E_Extension_MessageM)
+	proto.RegisterExtension(E_Extensiongroup)
+	proto.RegisterExtension(E_ExtraMessage)
+	proto.RegisterExtension(E_RepeatedXBool)
+	proto.RegisterExtension(E_RepeatedXEnum)
+	proto.RegisterExtension(E_RepeatedXInt32)
+	proto.RegisterExtension(E_RepeatedXSint32)
+	proto.RegisterExtension(E_RepeatedXUint32)
+	proto.RegisterExtension(E_RepeatedXInt64)
+	proto.RegisterExtension(E_RepeatedXSint64)
+	proto.RegisterExtension(E_RepeatedXUint64)
+	proto.RegisterExtension(E_RepeatedXSfixed32)
+	proto.RegisterExtension(E_RepeatedXFixed32)
+	proto.RegisterExtension(E_RepeatedXFloat)
+	proto.RegisterExtension(E_RepeatedXSfixed64)
+	proto.RegisterExtension(E_RepeatedXFixed64)
+	proto.RegisterExtension(E_RepeatedXDouble)
+	proto.RegisterExtension(E_RepeatedXString)
+	proto.RegisterExtension(E_RepeatedXBytes)
+	proto.RegisterExtension(E_RepeatedX_Message)
+	proto.RegisterExtension(E_Repeatedgroup)
+	proto.RegisterExtension(E_ExtendableField)
+	proto.RegisterExtension(E_ExtendableStringField)
+	proto.RegisterExtension(E_MessageSetExtension)
+	proto.RegisterExtension(E_ExtendingMessage_ExtendingMessageString)
+	proto.RegisterExtension(E_ExtendingMessage_ExtendingMessageSubmessage)
+	proto.RegisterExtension(E_MessageSetWireFormatExtension_MessageSetExtension)
 	xxx_File_extensions_ext_ext_proto_goTypes = nil
 	xxx_File_extensions_ext_ext_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go

@@ -54,11 +54,6 @@ func (m *ExtraMessage) GetData() []byte {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("extensions/extra/extra.proto", xxx_File_extensions_extra_extra_proto_rawdesc_gzipped)
-	proto.RegisterType((*ExtraMessage)(nil), "goproto.protoc.extension.extra.ExtraMessage")
-}
-
 var xxx_File_extensions_extra_extra_proto_rawdesc = []byte{
 	// 175 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1c, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x65, 0x78, 0x74,
@@ -103,6 +98,8 @@ func xxx_File_extensions_extra_extra_proto_init() {
 		xxx_File_extensions_extra_extra_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_extensions_extra_extra_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("extensions/extra/extra.proto", xxx_File_extensions_extra_extra_proto_rawdesc_gzipped)
+	proto.RegisterType((*ExtraMessage)(nil), "goproto.protoc.extension.extra.ExtraMessage")
 	xxx_File_extensions_extra_extra_proto_goTypes = nil
 	xxx_File_extensions_extra_extra_proto_depIdxs = nil
 }

+ 37 - 41
cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go

@@ -456,47 +456,6 @@ var (
 	// extend google.protobuf.MessageOptions { repeated goproto.protoc.extension.proto3.Message repeated_extension_Message = 2017; }
 	E_RepeatedExtension_Message = &xxx_File_extensions_proto3_ext3_proto_extDescs[33]
 )
-
-func init() {
-	proto.RegisterFile("extensions/proto3/ext3.proto", xxx_File_extensions_proto3_ext3_proto_rawdesc_gzipped)
-	proto.RegisterEnum("goproto.protoc.extension.proto3.Enum", Enum_name, Enum_value)
-	proto.RegisterType((*Message)(nil), "goproto.protoc.extension.proto3.Message")
-	proto.RegisterExtension(E_ExtensionBool)
-	proto.RegisterExtension(E_ExtensionEnum)
-	proto.RegisterExtension(E_ExtensionInt32)
-	proto.RegisterExtension(E_ExtensionSint32)
-	proto.RegisterExtension(E_ExtensionUint32)
-	proto.RegisterExtension(E_ExtensionInt64)
-	proto.RegisterExtension(E_ExtensionSint64)
-	proto.RegisterExtension(E_ExtensionUint64)
-	proto.RegisterExtension(E_ExtensionSfixed32)
-	proto.RegisterExtension(E_ExtensionFixed32)
-	proto.RegisterExtension(E_ExtensionFloat)
-	proto.RegisterExtension(E_ExtensionSfixed64)
-	proto.RegisterExtension(E_ExtensionFixed64)
-	proto.RegisterExtension(E_ExtensionDouble)
-	proto.RegisterExtension(E_ExtensionString)
-	proto.RegisterExtension(E_ExtensionBytes)
-	proto.RegisterExtension(E_Extension_Message)
-	proto.RegisterExtension(E_RepeatedExtensionBool)
-	proto.RegisterExtension(E_RepeatedExtensionEnum)
-	proto.RegisterExtension(E_RepeatedExtensionInt32)
-	proto.RegisterExtension(E_RepeatedExtensionSint32)
-	proto.RegisterExtension(E_RepeatedExtensionUint32)
-	proto.RegisterExtension(E_RepeatedExtensionInt64)
-	proto.RegisterExtension(E_RepeatedExtensionSint64)
-	proto.RegisterExtension(E_RepeatedExtensionUint64)
-	proto.RegisterExtension(E_RepeatedExtensionSfixed32)
-	proto.RegisterExtension(E_RepeatedExtensionFixed32)
-	proto.RegisterExtension(E_RepeatedExtensionFloat)
-	proto.RegisterExtension(E_RepeatedExtensionSfixed64)
-	proto.RegisterExtension(E_RepeatedExtensionFixed64)
-	proto.RegisterExtension(E_RepeatedExtensionDouble)
-	proto.RegisterExtension(E_RepeatedExtensionString)
-	proto.RegisterExtension(E_RepeatedExtensionBytes)
-	proto.RegisterExtension(E_RepeatedExtension_Message)
-}
-
 var xxx_File_extensions_proto3_ext3_proto_rawdesc = []byte{
 	// 3278 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1c, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x70, 0x72, 0x6f,
@@ -781,6 +740,43 @@ func xxx_File_extensions_proto3_ext3_proto_init() {
 		xxx_File_extensions_proto3_ext3_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_extensions_proto3_ext3_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("extensions/proto3/ext3.proto", xxx_File_extensions_proto3_ext3_proto_rawdesc_gzipped)
+	proto.RegisterEnum("goproto.protoc.extension.proto3.Enum", Enum_name, Enum_value)
+	proto.RegisterType((*Message)(nil), "goproto.protoc.extension.proto3.Message")
+	proto.RegisterExtension(E_ExtensionBool)
+	proto.RegisterExtension(E_ExtensionEnum)
+	proto.RegisterExtension(E_ExtensionInt32)
+	proto.RegisterExtension(E_ExtensionSint32)
+	proto.RegisterExtension(E_ExtensionUint32)
+	proto.RegisterExtension(E_ExtensionInt64)
+	proto.RegisterExtension(E_ExtensionSint64)
+	proto.RegisterExtension(E_ExtensionUint64)
+	proto.RegisterExtension(E_ExtensionSfixed32)
+	proto.RegisterExtension(E_ExtensionFixed32)
+	proto.RegisterExtension(E_ExtensionFloat)
+	proto.RegisterExtension(E_ExtensionSfixed64)
+	proto.RegisterExtension(E_ExtensionFixed64)
+	proto.RegisterExtension(E_ExtensionDouble)
+	proto.RegisterExtension(E_ExtensionString)
+	proto.RegisterExtension(E_ExtensionBytes)
+	proto.RegisterExtension(E_Extension_Message)
+	proto.RegisterExtension(E_RepeatedExtensionBool)
+	proto.RegisterExtension(E_RepeatedExtensionEnum)
+	proto.RegisterExtension(E_RepeatedExtensionInt32)
+	proto.RegisterExtension(E_RepeatedExtensionSint32)
+	proto.RegisterExtension(E_RepeatedExtensionUint32)
+	proto.RegisterExtension(E_RepeatedExtensionInt64)
+	proto.RegisterExtension(E_RepeatedExtensionSint64)
+	proto.RegisterExtension(E_RepeatedExtensionUint64)
+	proto.RegisterExtension(E_RepeatedExtensionSfixed32)
+	proto.RegisterExtension(E_RepeatedExtensionFixed32)
+	proto.RegisterExtension(E_RepeatedExtensionFloat)
+	proto.RegisterExtension(E_RepeatedExtensionSfixed64)
+	proto.RegisterExtension(E_RepeatedExtensionFixed64)
+	proto.RegisterExtension(E_RepeatedExtensionDouble)
+	proto.RegisterExtension(E_RepeatedExtensionString)
+	proto.RegisterExtension(E_RepeatedExtensionBytes)
+	proto.RegisterExtension(E_RepeatedExtension_Message)
 	xxx_File_extensions_proto3_ext3_proto_goTypes = nil
 	xxx_File_extensions_proto3_ext3_proto_depIdxs = nil
 }

+ 3 - 6
cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go

@@ -314,12 +314,6 @@ func (m *Message_OneofMessageConflict) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_Message_OneofMessageConflict proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("fieldnames/fieldnames.proto", xxx_File_fieldnames_fieldnames_proto_rawdesc_gzipped)
-	proto.RegisterType((*Message)(nil), "goproto.protoc.fieldnames.Message")
-	proto.RegisterType((*Message_OneofMessageConflict)(nil), "goproto.protoc.fieldnames.Message.OneofMessageConflict")
-}
-
 var xxx_File_fieldnames_fieldnames_proto_rawdesc = []byte{
 	// 826 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1b, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x2f, 0x66, 0x69, 0x65,
@@ -406,6 +400,9 @@ func xxx_File_fieldnames_fieldnames_proto_init() {
 		xxx_File_fieldnames_fieldnames_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_fieldnames_fieldnames_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("fieldnames/fieldnames.proto", xxx_File_fieldnames_fieldnames_proto_rawdesc_gzipped)
+	proto.RegisterType((*Message)(nil), "goproto.protoc.fieldnames.Message")
+	proto.RegisterType((*Message_OneofMessageConflict)(nil), "goproto.protoc.fieldnames.Message.OneofMessageConflict")
 	xxx_File_fieldnames_fieldnames_proto_goTypes = nil
 	xxx_File_fieldnames_fieldnames_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/import_public/a.pb.go

@@ -114,11 +114,6 @@ func (m *Public) GetLocal() *Local {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("import_public/a.proto", xxx_File_import_public_a_proto_rawdesc_gzipped)
-	proto.RegisterType((*Public)(nil), "goproto.protoc.import_public.Public")
-}
-
 var xxx_File_import_public_a_proto_rawdesc = []byte{
 	// 383 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x15, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2f,
@@ -184,6 +179,8 @@ func xxx_File_import_public_a_proto_init() {
 		xxx_File_import_public_a_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_import_public_a_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("import_public/a.proto", xxx_File_import_public_a_proto_rawdesc_gzipped)
+	proto.RegisterType((*Public)(nil), "goproto.protoc.import_public.Public")
 	xxx_File_import_public_a_proto_goTypes = nil
 	xxx_File_import_public_a_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/import_public/b.pb.go

@@ -63,11 +63,6 @@ func (m *Local) GetE() sub.E {
 	return sub.E_ZERO
 }
 
-func init() {
-	proto.RegisterFile("import_public/b.proto", xxx_File_import_public_b_proto_rawdesc_gzipped)
-	proto.RegisterType((*Local)(nil), "goproto.protoc.import_public.Local")
-}
-
 var xxx_File_import_public_b_proto_rawdesc = []byte{
 	// 265 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x15, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2f,
@@ -123,6 +118,8 @@ func xxx_File_import_public_b_proto_init() {
 		xxx_File_import_public_b_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_import_public_b_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("import_public/b.proto", xxx_File_import_public_b_proto_rawdesc_gzipped)
+	proto.RegisterType((*Local)(nil), "goproto.protoc.import_public.Local")
 	xxx_File_import_public_b_proto_goTypes = nil
 	xxx_File_import_public_b_proto_depIdxs = nil
 }

+ 7 - 11
cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go

@@ -386,17 +386,6 @@ var (
 	// extend goproto.protoc.import_public.sub.M { optional string extension_field = 100; }
 	E_ExtensionField = &xxx_File_import_public_sub_a_proto_extDescs[0]
 )
-
-func init() {
-	proto.RegisterFile("import_public/sub/a.proto", xxx_File_import_public_sub_a_proto_rawdesc_gzipped)
-	proto.RegisterEnum("goproto.protoc.import_public.sub.E", E_name, E_value)
-	proto.RegisterEnum("goproto.protoc.import_public.sub.M_Subenum", M_Subenum_name, M_Subenum_value)
-	proto.RegisterEnum("goproto.protoc.import_public.sub.M_Submessage_Submessage_Subenum", M_Submessage_Submessage_Subenum_name, M_Submessage_Submessage_Subenum_value)
-	proto.RegisterType((*M)(nil), "goproto.protoc.import_public.sub.M")
-	proto.RegisterType((*M_Submessage)(nil), "goproto.protoc.import_public.sub.M.Submessage")
-	proto.RegisterExtension(E_ExtensionField)
-}
-
 var xxx_File_import_public_sub_a_proto_rawdesc = []byte{
 	// 730 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2f,
@@ -490,6 +479,13 @@ func xxx_File_import_public_sub_a_proto_init() {
 		xxx_File_import_public_sub_a_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_import_public_sub_a_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("import_public/sub/a.proto", xxx_File_import_public_sub_a_proto_rawdesc_gzipped)
+	proto.RegisterEnum("goproto.protoc.import_public.sub.E", E_name, E_value)
+	proto.RegisterEnum("goproto.protoc.import_public.sub.M_Subenum", M_Subenum_name, M_Subenum_value)
+	proto.RegisterEnum("goproto.protoc.import_public.sub.M_Submessage_Submessage_Subenum", M_Submessage_Submessage_Subenum_name, M_Submessage_Submessage_Subenum_value)
+	proto.RegisterType((*M)(nil), "goproto.protoc.import_public.sub.M")
+	proto.RegisterType((*M_Submessage)(nil), "goproto.protoc.import_public.sub.M.Submessage")
+	proto.RegisterExtension(E_ExtensionField)
 	xxx_File_import_public_sub_a_proto_goTypes = nil
 	xxx_File_import_public_sub_a_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go

@@ -46,11 +46,6 @@ func (m *M2) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_M2 proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("import_public/sub/b.proto", xxx_File_import_public_sub_b_proto_rawdesc_gzipped)
-	proto.RegisterType((*M2)(nil), "goproto.protoc.import_public.sub.M2")
-}
-
 var xxx_File_import_public_sub_b_proto_rawdesc = []byte{
 	// 145 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2f,
@@ -94,6 +89,8 @@ func xxx_File_import_public_sub_b_proto_init() {
 		xxx_File_import_public_sub_b_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_import_public_sub_b_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("import_public/sub/b.proto", xxx_File_import_public_sub_b_proto_rawdesc_gzipped)
+	proto.RegisterType((*M2)(nil), "goproto.protoc.import_public.sub.M2")
 	xxx_File_import_public_sub_b_proto_goTypes = nil
 	xxx_File_import_public_sub_b_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go

@@ -46,11 +46,6 @@ func (m *Sub2Message) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_Sub2Message proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("import_public/sub2/a.proto", xxx_File_import_public_sub2_a_proto_rawdesc_gzipped)
-	proto.RegisterType((*Sub2Message)(nil), "goproto.protoc.import_public.sub2.Sub2Message")
-}
-
 var xxx_File_import_public_sub2_a_proto_rawdesc = []byte{
 	// 157 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1a, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2f,
@@ -94,6 +89,8 @@ func xxx_File_import_public_sub2_a_proto_init() {
 		xxx_File_import_public_sub2_a_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_import_public_sub2_a_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("import_public/sub2/a.proto", xxx_File_import_public_sub2_a_proto_rawdesc_gzipped)
+	proto.RegisterType((*Sub2Message)(nil), "goproto.protoc.import_public.sub2.Sub2Message")
 	xxx_File_import_public_sub2_a_proto_goTypes = nil
 	xxx_File_import_public_sub2_a_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go

@@ -46,11 +46,6 @@ func (m *M) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_M proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("imports/fmt/m.proto", xxx_File_imports_fmt_m_proto_rawdesc_gzipped)
-	proto.RegisterType((*M)(nil), "fmt.M")
-}
-
 var xxx_File_imports_fmt_m_proto_rawdesc = []byte{
 	// 111 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x13, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x66, 0x6d, 0x74, 0x2f, 0x6d, 0x2e,
@@ -91,6 +86,8 @@ func xxx_File_imports_fmt_m_proto_init() {
 		xxx_File_imports_fmt_m_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_imports_fmt_m_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("imports/fmt/m.proto", xxx_File_imports_fmt_m_proto_rawdesc_gzipped)
+	proto.RegisterType((*M)(nil), "fmt.M")
 	xxx_File_imports_fmt_m_proto_goTypes = nil
 	xxx_File_imports_fmt_m_proto_depIdxs = nil
 }

+ 4 - 7
cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go

@@ -122,13 +122,6 @@ func (m *M1_1) GetM1() *M1 {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("imports/test_a_1/m1.proto", xxx_File_imports_test_a_1_m1_proto_rawdesc_gzipped)
-	proto.RegisterEnum("test.a.E1", E1_name, E1_value)
-	proto.RegisterType((*M1)(nil), "test.a.M1")
-	proto.RegisterType((*M1_1)(nil), "test.a.M1_1")
-}
-
 var xxx_File_imports_test_a_1_m1_proto_rawdesc = []byte{
 	// 181 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61,
@@ -180,6 +173,10 @@ func xxx_File_imports_test_a_1_m1_proto_init() {
 		xxx_File_imports_test_a_1_m1_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_imports_test_a_1_m1_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("imports/test_a_1/m1.proto", xxx_File_imports_test_a_1_m1_proto_rawdesc_gzipped)
+	proto.RegisterEnum("test.a.E1", E1_name, E1_value)
+	proto.RegisterType((*M1)(nil), "test.a.M1")
+	proto.RegisterType((*M1_1)(nil), "test.a.M1_1")
 	xxx_File_imports_test_a_1_m1_proto_goTypes = nil
 	xxx_File_imports_test_a_1_m1_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go

@@ -46,11 +46,6 @@ func (m *M2) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_M2 proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("imports/test_a_1/m2.proto", xxx_File_imports_test_a_1_m2_proto_rawdesc_gzipped)
-	proto.RegisterType((*M2)(nil), "test.a.M2")
-}
-
 var xxx_File_imports_test_a_1_m2_proto_rawdesc = []byte{
 	// 126 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61,
@@ -92,6 +87,8 @@ func xxx_File_imports_test_a_1_m2_proto_init() {
 		xxx_File_imports_test_a_1_m2_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_imports_test_a_1_m2_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("imports/test_a_1/m2.proto", xxx_File_imports_test_a_1_m2_proto_rawdesc_gzipped)
+	proto.RegisterType((*M2)(nil), "test.a.M2")
 	xxx_File_imports_test_a_1_m2_proto_goTypes = nil
 	xxx_File_imports_test_a_1_m2_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go

@@ -46,11 +46,6 @@ func (m *M3) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_M3 proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("imports/test_a_2/m3.proto", xxx_File_imports_test_a_2_m3_proto_rawdesc_gzipped)
-	proto.RegisterType((*M3)(nil), "test.a.M3")
-}
-
 var xxx_File_imports_test_a_2_m3_proto_rawdesc = []byte{
 	// 126 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61,
@@ -92,6 +87,8 @@ func xxx_File_imports_test_a_2_m3_proto_init() {
 		xxx_File_imports_test_a_2_m3_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_imports_test_a_2_m3_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("imports/test_a_2/m3.proto", xxx_File_imports_test_a_2_m3_proto_rawdesc_gzipped)
+	proto.RegisterType((*M3)(nil), "test.a.M3")
 	xxx_File_imports_test_a_2_m3_proto_goTypes = nil
 	xxx_File_imports_test_a_2_m3_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go

@@ -46,11 +46,6 @@ func (m *M4) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_M4 proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("imports/test_a_2/m4.proto", xxx_File_imports_test_a_2_m4_proto_rawdesc_gzipped)
-	proto.RegisterType((*M4)(nil), "test.a.M4")
-}
-
 var xxx_File_imports_test_a_2_m4_proto_rawdesc = []byte{
 	// 126 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61,
@@ -92,6 +87,8 @@ func xxx_File_imports_test_a_2_m4_proto_init() {
 		xxx_File_imports_test_a_2_m4_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_imports_test_a_2_m4_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("imports/test_a_2/m4.proto", xxx_File_imports_test_a_2_m4_proto_rawdesc_gzipped)
+	proto.RegisterType((*M4)(nil), "test.a.M4")
 	xxx_File_imports_test_a_2_m4_proto_goTypes = nil
 	xxx_File_imports_test_a_2_m4_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go

@@ -46,11 +46,6 @@ func (m *M1) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_M1 proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("imports/test_b_1/m1.proto", xxx_File_imports_test_b_1_m1_proto_rawdesc_gzipped)
-	proto.RegisterType((*M1)(nil), "test.b.part1.M1")
-}
-
 var xxx_File_imports_test_b_1_m1_proto_rawdesc = []byte{
 	// 137 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62,
@@ -93,6 +88,8 @@ func xxx_File_imports_test_b_1_m1_proto_init() {
 		xxx_File_imports_test_b_1_m1_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_imports_test_b_1_m1_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("imports/test_b_1/m1.proto", xxx_File_imports_test_b_1_m1_proto_rawdesc_gzipped)
+	proto.RegisterType((*M1)(nil), "test.b.part1.M1")
 	xxx_File_imports_test_b_1_m1_proto_goTypes = nil
 	xxx_File_imports_test_b_1_m1_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go

@@ -46,11 +46,6 @@ func (m *M2) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_M2 proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("imports/test_b_1/m2.proto", xxx_File_imports_test_b_1_m2_proto_rawdesc_gzipped)
-	proto.RegisterType((*M2)(nil), "test.b.part2.M2")
-}
-
 var xxx_File_imports_test_b_1_m2_proto_rawdesc = []byte{
 	// 137 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62,
@@ -93,6 +88,8 @@ func xxx_File_imports_test_b_1_m2_proto_init() {
 		xxx_File_imports_test_b_1_m2_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_imports_test_b_1_m2_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("imports/test_b_1/m2.proto", xxx_File_imports_test_b_1_m2_proto_rawdesc_gzipped)
+	proto.RegisterType((*M2)(nil), "test.b.part2.M2")
 	xxx_File_imports_test_b_1_m2_proto_goTypes = nil
 	xxx_File_imports_test_b_1_m2_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go

@@ -55,11 +55,6 @@ func (m *A1M1) GetF() *test_a_1.M1 {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("imports/test_import_a1m1.proto", xxx_File_imports_test_import_a1m1_proto_rawdesc_gzipped)
-	proto.RegisterType((*A1M1)(nil), "test.A1M1")
-}
-
 var xxx_File_imports_test_import_a1m1_proto_rawdesc = []byte{
 	// 175 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1e, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x69,
@@ -107,6 +102,8 @@ func xxx_File_imports_test_import_a1m1_proto_init() {
 		xxx_File_imports_test_import_a1m1_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_imports_test_import_a1m1_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("imports/test_import_a1m1.proto", xxx_File_imports_test_import_a1m1_proto_rawdesc_gzipped)
+	proto.RegisterType((*A1M1)(nil), "test.A1M1")
 	xxx_File_imports_test_import_a1m1_proto_goTypes = nil
 	xxx_File_imports_test_import_a1m1_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go

@@ -55,11 +55,6 @@ func (m *A1M2) GetF() *test_a_1.M2 {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("imports/test_import_a1m2.proto", xxx_File_imports_test_import_a1m2_proto_rawdesc_gzipped)
-	proto.RegisterType((*A1M2)(nil), "test.A1M2")
-}
-
 var xxx_File_imports_test_import_a1m2_proto_rawdesc = []byte{
 	// 175 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1e, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x69,
@@ -107,6 +102,8 @@ func xxx_File_imports_test_import_a1m2_proto_init() {
 		xxx_File_imports_test_import_a1m2_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_imports_test_import_a1m2_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("imports/test_import_a1m2.proto", xxx_File_imports_test_import_a1m2_proto_rawdesc_gzipped)
+	proto.RegisterType((*A1M2)(nil), "test.A1M2")
 	xxx_File_imports_test_import_a1m2_proto_goTypes = nil
 	xxx_File_imports_test_import_a1m2_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go

@@ -90,11 +90,6 @@ func (m *All) GetFmt() *fmt.M {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("imports/test_import_all.proto", xxx_File_imports_test_import_all_proto_rawdesc_gzipped)
-	proto.RegisterType((*All)(nil), "test.All")
-}
-
 var xxx_File_imports_test_import_all_proto_rawdesc = []byte{
 	// 462 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1d, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x69,
@@ -168,6 +163,8 @@ func xxx_File_imports_test_import_all_proto_init() {
 		xxx_File_imports_test_import_all_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_imports_test_import_all_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("imports/test_import_all.proto", xxx_File_imports_test_import_all_proto_rawdesc_gzipped)
+	proto.RegisterType((*All)(nil), "test.All")
 	xxx_File_imports_test_import_all_proto_goTypes = nil
 	xxx_File_imports_test_import_all_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go

@@ -80,11 +80,6 @@ func (*Foo) XXX_OneofWrappers() []interface{} {
 	}
 }
 
-func init() {
-	proto.RegisterFile("issue780_oneof_conflict/test.proto", xxx_File_issue780_oneof_conflict_test_proto_rawdesc_gzipped)
-	proto.RegisterType((*Foo)(nil), "oneoftest.Foo")
-}
-
 var xxx_File_issue780_oneof_conflict_test_proto_rawdesc = []byte{
 	// 88 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x22, 0x69, 0x73, 0x73, 0x75, 0x65, 0x37, 0x38, 0x30, 0x5f, 0x6f, 0x6e, 0x65, 0x6f, 0x66,
@@ -124,6 +119,8 @@ func xxx_File_issue780_oneof_conflict_test_proto_init() {
 		xxx_File_issue780_oneof_conflict_test_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_issue780_oneof_conflict_test_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("issue780_oneof_conflict/test.proto", xxx_File_issue780_oneof_conflict_test_proto_rawdesc_gzipped)
+	proto.RegisterType((*Foo)(nil), "oneoftest.Foo")
 	xxx_File_issue780_oneof_conflict_test_proto_goTypes = nil
 	xxx_File_issue780_oneof_conflict_test_proto_depIdxs = nil
 }

+ 3 - 6
cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go

@@ -110,12 +110,6 @@ func (m *Message) GetEnumField() Enum {
 	return Default_Message_EnumField
 }
 
-func init() {
-	proto.RegisterFile("nopackage/nopackage.proto", xxx_File_nopackage_nopackage_proto_rawdesc_gzipped)
-	proto.RegisterEnum("Enum", Enum_name, Enum_value)
-	proto.RegisterType((*Message)(nil), "Message")
-}
-
 var xxx_File_nopackage_nopackage_proto_rawdesc = []byte{
 	// 135 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x6e, 0x6f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2f, 0x6e, 0x6f, 0x70, 0x61,
@@ -163,6 +157,9 @@ func xxx_File_nopackage_nopackage_proto_init() {
 		xxx_File_nopackage_nopackage_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_nopackage_nopackage_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("nopackage/nopackage.proto", xxx_File_nopackage_nopackage_proto_rawdesc_gzipped)
+	proto.RegisterEnum("Enum", Enum_name, Enum_value)
+	proto.RegisterType((*Message)(nil), "Message")
 	xxx_File_nopackage_nopackage_proto_goTypes = nil
 	xxx_File_nopackage_nopackage_proto_depIdxs = nil
 }

+ 9 - 12
cmd/protoc-gen-go/testdata/proto2/enum.pb.go

@@ -394,18 +394,6 @@ func (m *EnumContainerMessage1_EnumContainerMessage2) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_EnumContainerMessage1_EnumContainerMessage2 proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("proto2/enum.proto", xxx_File_proto2_enum_proto_rawdesc_gzipped)
-	proto.RegisterEnum("goproto.protoc.proto2.EnumType1", EnumType1_name, EnumType1_value)
-	proto.RegisterEnum("goproto.protoc.proto2.EnumType2", EnumType2_name, EnumType2_value)
-	proto.RegisterEnum("goproto.protoc.proto2.EnumContainerMessage1_NestedEnumType1A", EnumContainerMessage1_NestedEnumType1A_name, EnumContainerMessage1_NestedEnumType1A_value)
-	proto.RegisterEnum("goproto.protoc.proto2.EnumContainerMessage1_NestedEnumType1B", EnumContainerMessage1_NestedEnumType1B_name, EnumContainerMessage1_NestedEnumType1B_value)
-	proto.RegisterEnum("goproto.protoc.proto2.EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A", EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A_name, EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A_value)
-	proto.RegisterEnum("goproto.protoc.proto2.EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B", EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B_name, EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B_value)
-	proto.RegisterType((*EnumContainerMessage1)(nil), "goproto.protoc.proto2.EnumContainerMessage1")
-	proto.RegisterType((*EnumContainerMessage1_EnumContainerMessage2)(nil), "goproto.protoc.proto2.EnumContainerMessage1.EnumContainerMessage2")
-}
-
 var xxx_File_proto2_enum_proto_rawdesc = []byte{
 	// 624 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2f, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x70, 0x72,
@@ -490,6 +478,15 @@ func xxx_File_proto2_enum_proto_init() {
 		xxx_File_proto2_enum_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_proto2_enum_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("proto2/enum.proto", xxx_File_proto2_enum_proto_rawdesc_gzipped)
+	proto.RegisterEnum("goproto.protoc.proto2.EnumType1", EnumType1_name, EnumType1_value)
+	proto.RegisterEnum("goproto.protoc.proto2.EnumType2", EnumType2_name, EnumType2_value)
+	proto.RegisterEnum("goproto.protoc.proto2.EnumContainerMessage1_NestedEnumType1A", EnumContainerMessage1_NestedEnumType1A_name, EnumContainerMessage1_NestedEnumType1A_value)
+	proto.RegisterEnum("goproto.protoc.proto2.EnumContainerMessage1_NestedEnumType1B", EnumContainerMessage1_NestedEnumType1B_name, EnumContainerMessage1_NestedEnumType1B_value)
+	proto.RegisterEnum("goproto.protoc.proto2.EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A", EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A_name, EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A_value)
+	proto.RegisterEnum("goproto.protoc.proto2.EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B", EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B_name, EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B_value)
+	proto.RegisterType((*EnumContainerMessage1)(nil), "goproto.protoc.proto2.EnumContainerMessage1")
+	proto.RegisterType((*EnumContainerMessage1_EnumContainerMessage2)(nil), "goproto.protoc.proto2.EnumContainerMessage1.EnumContainerMessage2")
 	xxx_File_proto2_enum_proto_goTypes = nil
 	xxx_File_proto2_enum_proto_depIdxs = nil
 }

+ 11 - 14
cmd/protoc-gen-go/testdata/proto2/fields.pb.go

@@ -1331,20 +1331,6 @@ func (m *FieldTestMessage_Message) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_FieldTestMessage_Message proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("proto2/fields.proto", xxx_File_proto2_fields_proto_rawdesc_gzipped)
-	proto.RegisterEnum("goproto.protoc.proto2.FieldTestMessage_Enum", FieldTestMessage_Enum_name, FieldTestMessage_Enum_value)
-	proto.RegisterType((*FieldTestMessage)(nil), "goproto.protoc.proto2.FieldTestMessage")
-	proto.RegisterMapType((map[uint64]FieldTestMessage_Enum)(nil), "goproto.protoc.proto2.FieldTestMessage.MapFixed64EnumEntry")
-	proto.RegisterMapType((map[int32]int64)(nil), "goproto.protoc.proto2.FieldTestMessage.MapInt32Int64Entry")
-	proto.RegisterMapType((map[string]*FieldTestMessage_Message)(nil), "goproto.protoc.proto2.FieldTestMessage.MapStringMessageEntry")
-	proto.RegisterType((*FieldTestMessage_OptionalGroup)(nil), "goproto.protoc.proto2.FieldTestMessage.OptionalGroup")
-	proto.RegisterType((*FieldTestMessage_RequiredGroup)(nil), "goproto.protoc.proto2.FieldTestMessage.RequiredGroup")
-	proto.RegisterType((*FieldTestMessage_RepeatedGroup)(nil), "goproto.protoc.proto2.FieldTestMessage.RepeatedGroup")
-	proto.RegisterType((*FieldTestMessage_OneofGroup)(nil), "goproto.protoc.proto2.FieldTestMessage.OneofGroup")
-	proto.RegisterType((*FieldTestMessage_Message)(nil), "goproto.protoc.proto2.FieldTestMessage.Message")
-}
-
 var xxx_File_proto2_fields_proto_rawdesc = []byte{
 	// 5913 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x2e,
@@ -1778,6 +1764,17 @@ func xxx_File_proto2_fields_proto_init() {
 		xxx_File_proto2_fields_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_proto2_fields_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("proto2/fields.proto", xxx_File_proto2_fields_proto_rawdesc_gzipped)
+	proto.RegisterEnum("goproto.protoc.proto2.FieldTestMessage_Enum", FieldTestMessage_Enum_name, FieldTestMessage_Enum_value)
+	proto.RegisterType((*FieldTestMessage)(nil), "goproto.protoc.proto2.FieldTestMessage")
+	proto.RegisterMapType((map[uint64]FieldTestMessage_Enum)(nil), "goproto.protoc.proto2.FieldTestMessage.MapFixed64EnumEntry")
+	proto.RegisterMapType((map[int32]int64)(nil), "goproto.protoc.proto2.FieldTestMessage.MapInt32Int64Entry")
+	proto.RegisterMapType((map[string]*FieldTestMessage_Message)(nil), "goproto.protoc.proto2.FieldTestMessage.MapStringMessageEntry")
+	proto.RegisterType((*FieldTestMessage_OptionalGroup)(nil), "goproto.protoc.proto2.FieldTestMessage.OptionalGroup")
+	proto.RegisterType((*FieldTestMessage_RequiredGroup)(nil), "goproto.protoc.proto2.FieldTestMessage.RequiredGroup")
+	proto.RegisterType((*FieldTestMessage_RepeatedGroup)(nil), "goproto.protoc.proto2.FieldTestMessage.RepeatedGroup")
+	proto.RegisterType((*FieldTestMessage_OneofGroup)(nil), "goproto.protoc.proto2.FieldTestMessage.OneofGroup")
+	proto.RegisterType((*FieldTestMessage_Message)(nil), "goproto.protoc.proto2.FieldTestMessage.Message")
 	xxx_File_proto2_fields_proto_goTypes = nil
 	xxx_File_proto2_fields_proto_depIdxs = nil
 }

+ 4 - 7
cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go

@@ -142,13 +142,6 @@ func (m *Layer1_Layer2_Layer3) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_Layer1_Layer2_Layer3 proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("proto2/nested_messages.proto", xxx_File_proto2_nested_messages_proto_rawdesc_gzipped)
-	proto.RegisterType((*Layer1)(nil), "goproto.protoc.proto2.Layer1")
-	proto.RegisterType((*Layer1_Layer2)(nil), "goproto.protoc.proto2.Layer1.Layer2")
-	proto.RegisterType((*Layer1_Layer2_Layer3)(nil), "goproto.protoc.proto2.Layer1.Layer2.Layer3")
-}
-
 var xxx_File_proto2_nested_messages_proto_rawdesc = []byte{
 	// 327 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f,
@@ -209,6 +202,10 @@ func xxx_File_proto2_nested_messages_proto_init() {
 		xxx_File_proto2_nested_messages_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_proto2_nested_messages_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("proto2/nested_messages.proto", xxx_File_proto2_nested_messages_proto_rawdesc_gzipped)
+	proto.RegisterType((*Layer1)(nil), "goproto.protoc.proto2.Layer1")
+	proto.RegisterType((*Layer1_Layer2)(nil), "goproto.protoc.proto2.Layer1.Layer2")
+	proto.RegisterType((*Layer1_Layer2_Layer3)(nil), "goproto.protoc.proto2.Layer1.Layer2.Layer3")
 	xxx_File_proto2_nested_messages_proto_goTypes = nil
 	xxx_File_proto2_nested_messages_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/proto2/proto2.pb.go

@@ -62,11 +62,6 @@ func (m *Message) GetM() *Message {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("proto2/proto2.proto", xxx_File_proto2_proto2_proto_rawdesc_gzipped)
-	proto.RegisterType((*Message)(nil), "goproto.protoc.proto2.Message")
-}
-
 var xxx_File_proto2_proto2_proto_rawdesc = []byte{
 	// 186 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2e,
@@ -114,6 +109,8 @@ func xxx_File_proto2_proto2_proto_init() {
 		xxx_File_proto2_proto2_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_proto2_proto2_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("proto2/proto2.proto", xxx_File_proto2_proto2_proto_rawdesc_gzipped)
+	proto.RegisterType((*Message)(nil), "goproto.protoc.proto2.Message")
 	xxx_File_proto2_proto2_proto_goTypes = nil
 	xxx_File_proto2_proto2_proto_depIdxs = nil
 }

+ 2 - 5
cmd/protoc-gen-go/testdata/proto3/enum.pb.go

@@ -47,11 +47,6 @@ func (Enum) EnumDescriptor() ([]byte, []int) {
 	return xxx_File_proto3_enum_proto_rawdesc_gzipped, []int{0}
 }
 
-func init() {
-	proto.RegisterFile("proto3/enum.proto", xxx_File_proto3_enum_proto_rawdesc_gzipped)
-	proto.RegisterEnum("goproto.protoc.proto3.Enum", Enum_name, Enum_value)
-}
-
 var xxx_File_proto3_enum_proto_rawdesc = []byte{
 	// 153 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x2f, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x70, 0x72,
@@ -89,6 +84,8 @@ func xxx_File_proto3_enum_proto_init() {
 		DependencyIndexes: xxx_File_proto3_enum_proto_depIdxs,
 		EnumOutputTypes:   xxx_File_proto3_enum_proto_enumTypes,
 	}.Init()
+	proto.RegisterFile("proto3/enum.proto", xxx_File_proto3_enum_proto_rawdesc_gzipped)
+	proto.RegisterEnum("goproto.protoc.proto3.Enum", Enum_name, Enum_value)
 	xxx_File_proto3_enum_proto_goTypes = nil
 	xxx_File_proto3_enum_proto_depIdxs = nil
 }

+ 7 - 10
cmd/protoc-gen-go/testdata/proto3/fields.pb.go

@@ -410,16 +410,6 @@ func (m *FieldTestMessage_Message) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_FieldTestMessage_Message proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("proto3/fields.proto", xxx_File_proto3_fields_proto_rawdesc_gzipped)
-	proto.RegisterEnum("goproto.protoc.proto3.FieldTestMessage_Enum", FieldTestMessage_Enum_name, FieldTestMessage_Enum_value)
-	proto.RegisterType((*FieldTestMessage)(nil), "goproto.protoc.proto3.FieldTestMessage")
-	proto.RegisterMapType((map[uint64]FieldTestMessage_Enum)(nil), "goproto.protoc.proto3.FieldTestMessage.MapFixed64EnumEntry")
-	proto.RegisterMapType((map[int32]int64)(nil), "goproto.protoc.proto3.FieldTestMessage.MapInt32Int64Entry")
-	proto.RegisterMapType((map[string]*FieldTestMessage_Message)(nil), "goproto.protoc.proto3.FieldTestMessage.MapStringMessageEntry")
-	proto.RegisterType((*FieldTestMessage_Message)(nil), "goproto.protoc.proto3.FieldTestMessage.Message")
-}
-
 var xxx_File_proto3_fields_proto_rawdesc = []byte{
 	// 2378 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x2e,
@@ -619,6 +609,13 @@ func xxx_File_proto3_fields_proto_init() {
 		xxx_File_proto3_fields_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_proto3_fields_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("proto3/fields.proto", xxx_File_proto3_fields_proto_rawdesc_gzipped)
+	proto.RegisterEnum("goproto.protoc.proto3.FieldTestMessage_Enum", FieldTestMessage_Enum_name, FieldTestMessage_Enum_value)
+	proto.RegisterType((*FieldTestMessage)(nil), "goproto.protoc.proto3.FieldTestMessage")
+	proto.RegisterMapType((map[uint64]FieldTestMessage_Enum)(nil), "goproto.protoc.proto3.FieldTestMessage.MapFixed64EnumEntry")
+	proto.RegisterMapType((map[int32]int64)(nil), "goproto.protoc.proto3.FieldTestMessage.MapInt32Int64Entry")
+	proto.RegisterMapType((map[string]*FieldTestMessage_Message)(nil), "goproto.protoc.proto3.FieldTestMessage.MapStringMessageEntry")
+	proto.RegisterType((*FieldTestMessage_Message)(nil), "goproto.protoc.proto3.FieldTestMessage.Message")
 	xxx_File_proto3_fields_proto_goTypes = nil
 	xxx_File_proto3_fields_proto_depIdxs = nil
 }

+ 42 - 46
encoding/testprotos/pb2/test.pb.go

@@ -1659,52 +1659,6 @@ var (
 	// extend pb2.FakeMessageSet { optional pb2.FakeMessageSetExtension message_set_extension = 10; }
 	E_FakeMessageSetExtension_MessageSetExtension = &xxx_File_pb2_test_proto_extDescs[18]
 )
-
-func init() {
-	proto.RegisterFile("pb2/test.proto", xxx_File_pb2_test_proto_rawdesc_gzipped)
-	proto.RegisterEnum("pb2.Enum", Enum_name, Enum_value)
-	proto.RegisterEnum("pb2.Enums_NestedEnum", Enums_NestedEnum_name, Enums_NestedEnum_value)
-	proto.RegisterType((*Scalars)(nil), "pb2.Scalars")
-	proto.RegisterType((*Enums)(nil), "pb2.Enums")
-	proto.RegisterType((*Repeats)(nil), "pb2.Repeats")
-	proto.RegisterType((*Nested)(nil), "pb2.Nested")
-	proto.RegisterType((*Nests)(nil), "pb2.Nests")
-	proto.RegisterType((*Requireds)(nil), "pb2.Requireds")
-	proto.RegisterType((*PartialRequired)(nil), "pb2.PartialRequired")
-	proto.RegisterType((*NestedWithRequired)(nil), "pb2.NestedWithRequired")
-	proto.RegisterType((*IndirectRequired)(nil), "pb2.IndirectRequired")
-	proto.RegisterMapType((map[string]*NestedWithRequired)(nil), "pb2.IndirectRequired.StrToNestedEntry")
-	proto.RegisterType((*Extensions)(nil), "pb2.Extensions")
-	proto.RegisterType((*ExtensionsContainer)(nil), "pb2.ExtensionsContainer")
-	proto.RegisterType((*MessageSet)(nil), "pb2.MessageSet")
-	proto.RegisterType((*MessageSetExtension)(nil), "pb2.MessageSetExtension")
-	proto.RegisterType((*FakeMessageSet)(nil), "pb2.FakeMessageSet")
-	proto.RegisterType((*FakeMessageSetExtension)(nil), "pb2.FakeMessageSetExtension")
-	proto.RegisterType((*KnownTypes)(nil), "pb2.KnownTypes")
-	proto.RegisterType((*Nests_OptGroup)(nil), "pb2.Nests.OptGroup")
-	proto.RegisterType((*Nests_RptGroup)(nil), "pb2.Nests.RptGroup")
-	proto.RegisterType((*Nests_OptGroup_OptNestedGroup)(nil), "pb2.Nests.OptGroup.OptNestedGroup")
-	proto.RegisterExtension(E_OptExtBool)
-	proto.RegisterExtension(E_OptExtString)
-	proto.RegisterExtension(E_OptExtEnum)
-	proto.RegisterExtension(E_OptExtNested)
-	proto.RegisterExtension(E_RptExtFixed32)
-	proto.RegisterExtension(E_RptExtEnum)
-	proto.RegisterExtension(E_RptExtNested)
-	proto.RegisterExtension(E_MessageSetExtension)
-	proto.RegisterExtension(E_ExtensionsContainer_OptExtBool)
-	proto.RegisterExtension(E_ExtensionsContainer_OptExtString)
-	proto.RegisterExtension(E_ExtensionsContainer_OptExtEnum)
-	proto.RegisterExtension(E_ExtensionsContainer_OptExtNested)
-	proto.RegisterExtension(E_ExtensionsContainer_RptExtString)
-	proto.RegisterExtension(E_ExtensionsContainer_RptExtEnum)
-	proto.RegisterExtension(E_ExtensionsContainer_RptExtNested)
-	proto.RegisterExtension(E_MessageSetExtension_MessageSetExtension)
-	proto.RegisterExtension(E_MessageSetExtension_NotMessageSetExtension)
-	proto.RegisterExtension(E_MessageSetExtension_ExtNested)
-	proto.RegisterExtension(E_FakeMessageSetExtension_MessageSetExtension)
-}
-
 var xxx_File_pb2_test_proto_rawdesc = []byte{
 	// 5126 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x0e, 0x70, 0x62, 0x32, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
@@ -2168,6 +2122,48 @@ func xxx_File_pb2_test_proto_init() {
 		xxx_File_pb2_test_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_pb2_test_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("pb2/test.proto", xxx_File_pb2_test_proto_rawdesc_gzipped)
+	proto.RegisterEnum("pb2.Enum", Enum_name, Enum_value)
+	proto.RegisterEnum("pb2.Enums_NestedEnum", Enums_NestedEnum_name, Enums_NestedEnum_value)
+	proto.RegisterType((*Scalars)(nil), "pb2.Scalars")
+	proto.RegisterType((*Enums)(nil), "pb2.Enums")
+	proto.RegisterType((*Repeats)(nil), "pb2.Repeats")
+	proto.RegisterType((*Nested)(nil), "pb2.Nested")
+	proto.RegisterType((*Nests)(nil), "pb2.Nests")
+	proto.RegisterType((*Requireds)(nil), "pb2.Requireds")
+	proto.RegisterType((*PartialRequired)(nil), "pb2.PartialRequired")
+	proto.RegisterType((*NestedWithRequired)(nil), "pb2.NestedWithRequired")
+	proto.RegisterType((*IndirectRequired)(nil), "pb2.IndirectRequired")
+	proto.RegisterMapType((map[string]*NestedWithRequired)(nil), "pb2.IndirectRequired.StrToNestedEntry")
+	proto.RegisterType((*Extensions)(nil), "pb2.Extensions")
+	proto.RegisterType((*ExtensionsContainer)(nil), "pb2.ExtensionsContainer")
+	proto.RegisterType((*MessageSet)(nil), "pb2.MessageSet")
+	proto.RegisterType((*MessageSetExtension)(nil), "pb2.MessageSetExtension")
+	proto.RegisterType((*FakeMessageSet)(nil), "pb2.FakeMessageSet")
+	proto.RegisterType((*FakeMessageSetExtension)(nil), "pb2.FakeMessageSetExtension")
+	proto.RegisterType((*KnownTypes)(nil), "pb2.KnownTypes")
+	proto.RegisterType((*Nests_OptGroup)(nil), "pb2.Nests.OptGroup")
+	proto.RegisterType((*Nests_RptGroup)(nil), "pb2.Nests.RptGroup")
+	proto.RegisterType((*Nests_OptGroup_OptNestedGroup)(nil), "pb2.Nests.OptGroup.OptNestedGroup")
+	proto.RegisterExtension(E_OptExtBool)
+	proto.RegisterExtension(E_OptExtString)
+	proto.RegisterExtension(E_OptExtEnum)
+	proto.RegisterExtension(E_OptExtNested)
+	proto.RegisterExtension(E_RptExtFixed32)
+	proto.RegisterExtension(E_RptExtEnum)
+	proto.RegisterExtension(E_RptExtNested)
+	proto.RegisterExtension(E_MessageSetExtension)
+	proto.RegisterExtension(E_ExtensionsContainer_OptExtBool)
+	proto.RegisterExtension(E_ExtensionsContainer_OptExtString)
+	proto.RegisterExtension(E_ExtensionsContainer_OptExtEnum)
+	proto.RegisterExtension(E_ExtensionsContainer_OptExtNested)
+	proto.RegisterExtension(E_ExtensionsContainer_RptExtString)
+	proto.RegisterExtension(E_ExtensionsContainer_RptExtEnum)
+	proto.RegisterExtension(E_ExtensionsContainer_RptExtNested)
+	proto.RegisterExtension(E_MessageSetExtension_MessageSetExtension)
+	proto.RegisterExtension(E_MessageSetExtension_NotMessageSetExtension)
+	proto.RegisterExtension(E_MessageSetExtension_ExtNested)
+	proto.RegisterExtension(E_FakeMessageSetExtension_MessageSetExtension)
 	xxx_File_pb2_test_proto_goTypes = nil
 	xxx_File_pb2_test_proto_depIdxs = nil
 }

+ 15 - 18
encoding/testprotos/pb3/test.pb.go

@@ -623,24 +623,6 @@ func (m *JSONNames) GetSString() string {
 	return ""
 }
 
-func init() {
-	proto.RegisterFile("pb3/test.proto", xxx_File_pb3_test_proto_rawdesc_gzipped)
-	proto.RegisterEnum("pb3.Enum", Enum_name, Enum_value)
-	proto.RegisterEnum("pb3.Enums_NestedEnum", Enums_NestedEnum_name, Enums_NestedEnum_value)
-	proto.RegisterType((*Scalars)(nil), "pb3.Scalars")
-	proto.RegisterType((*Enums)(nil), "pb3.Enums")
-	proto.RegisterType((*Nests)(nil), "pb3.Nests")
-	proto.RegisterType((*Nested)(nil), "pb3.Nested")
-	proto.RegisterType((*Oneofs)(nil), "pb3.Oneofs")
-	proto.RegisterType((*Maps)(nil), "pb3.Maps")
-	proto.RegisterMapType((map[bool]uint32)(nil), "pb3.Maps.BoolToUint32Entry")
-	proto.RegisterMapType((map[int32]string)(nil), "pb3.Maps.Int32ToStrEntry")
-	proto.RegisterMapType((map[string]*Nested)(nil), "pb3.Maps.StrToNestedEntry")
-	proto.RegisterMapType((map[string]*Oneofs)(nil), "pb3.Maps.StrToOneofsEntry")
-	proto.RegisterMapType((map[uint64]Enum)(nil), "pb3.Maps.Uint64ToEnumEntry")
-	proto.RegisterType((*JSONNames)(nil), "pb3.JSONNames")
-}
-
 var xxx_File_pb3_test_proto_rawdesc = []byte{
 	// 1710 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x0e, 0x70, 0x62, 0x33, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
@@ -811,6 +793,21 @@ func xxx_File_pb3_test_proto_init() {
 		xxx_File_pb3_test_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_pb3_test_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("pb3/test.proto", xxx_File_pb3_test_proto_rawdesc_gzipped)
+	proto.RegisterEnum("pb3.Enum", Enum_name, Enum_value)
+	proto.RegisterEnum("pb3.Enums_NestedEnum", Enums_NestedEnum_name, Enums_NestedEnum_value)
+	proto.RegisterType((*Scalars)(nil), "pb3.Scalars")
+	proto.RegisterType((*Enums)(nil), "pb3.Enums")
+	proto.RegisterType((*Nests)(nil), "pb3.Nests")
+	proto.RegisterType((*Nested)(nil), "pb3.Nested")
+	proto.RegisterType((*Oneofs)(nil), "pb3.Oneofs")
+	proto.RegisterType((*Maps)(nil), "pb3.Maps")
+	proto.RegisterMapType((map[bool]uint32)(nil), "pb3.Maps.BoolToUint32Entry")
+	proto.RegisterMapType((map[int32]string)(nil), "pb3.Maps.Int32ToStrEntry")
+	proto.RegisterMapType((map[string]*Nested)(nil), "pb3.Maps.StrToNestedEntry")
+	proto.RegisterMapType((map[string]*Oneofs)(nil), "pb3.Maps.StrToOneofsEntry")
+	proto.RegisterMapType((map[uint64]Enum)(nil), "pb3.Maps.Uint64ToEnumEntry")
+	proto.RegisterType((*JSONNames)(nil), "pb3.JSONNames")
 	xxx_File_pb3_test_proto_goTypes = nil
 	xxx_File_pb3_test_proto_depIdxs = nil
 }

+ 7 - 10
internal/testprotos/conformance/conformance.pb.go

@@ -569,16 +569,6 @@ func (m *JspbEncodingConfig) GetUseJspbArrayAnyFormat() bool {
 	return false
 }
 
-func init() {
-	proto.RegisterFile("conformance/conformance.proto", xxx_File_conformance_conformance_proto_rawdesc_gzipped)
-	proto.RegisterEnum("conformance.WireFormat", WireFormat_name, WireFormat_value)
-	proto.RegisterEnum("conformance.TestCategory", TestCategory_name, TestCategory_value)
-	proto.RegisterType((*FailureSet)(nil), "conformance.FailureSet")
-	proto.RegisterType((*ConformanceRequest)(nil), "conformance.ConformanceRequest")
-	proto.RegisterType((*ConformanceResponse)(nil), "conformance.ConformanceResponse")
-	proto.RegisterType((*JspbEncodingConfig)(nil), "conformance.JspbEncodingConfig")
-}
-
 var xxx_File_conformance_conformance_proto_rawdesc = []byte{
 	// 1306 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1d, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2f, 0x63, 0x6f,
@@ -705,6 +695,13 @@ func xxx_File_conformance_conformance_proto_init() {
 		xxx_File_conformance_conformance_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_conformance_conformance_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("conformance/conformance.proto", xxx_File_conformance_conformance_proto_rawdesc_gzipped)
+	proto.RegisterEnum("conformance.WireFormat", WireFormat_name, WireFormat_value)
+	proto.RegisterEnum("conformance.TestCategory", TestCategory_name, TestCategory_value)
+	proto.RegisterType((*FailureSet)(nil), "conformance.FailureSet")
+	proto.RegisterType((*ConformanceRequest)(nil), "conformance.ConformanceRequest")
+	proto.RegisterType((*ConformanceResponse)(nil), "conformance.ConformanceResponse")
+	proto.RegisterType((*JspbEncodingConfig)(nil), "conformance.JspbEncodingConfig")
 	xxx_File_conformance_conformance_proto_goTypes = nil
 	xxx_File_conformance_conformance_proto_depIdxs = nil
 }

+ 2 - 5
internal/testprotos/legacy/legacy.pb.go

@@ -154,11 +154,6 @@ func (m *Legacy) GetF12() *proto3_v1_21.Message {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("legacy/legacy.proto", xxx_File_legacy_legacy_proto_rawdesc_gzipped)
-	proto.RegisterType((*Legacy)(nil), "google.golang.org.Legacy")
-}
-
 var xxx_File_legacy_legacy_proto_rawdesc = []byte{
 	// 1457 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x13, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x2f, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x2e,
@@ -309,6 +304,8 @@ func xxx_File_legacy_legacy_proto_init() {
 		xxx_File_legacy_legacy_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_legacy_legacy_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("legacy/legacy.proto", xxx_File_legacy_legacy_proto_rawdesc_gzipped)
+	proto.RegisterType((*Legacy)(nil), "google.golang.org.Legacy")
 	xxx_File_legacy_legacy_proto_goTypes = nil
 	xxx_File_legacy_legacy_proto_depIdxs = nil
 }

+ 2 - 6
internal/testprotos/test/ext.pb.go

@@ -23,12 +23,6 @@ var (
 	// extend goproto.proto.test.TestAllExtensions { optional int32 foreign_int32_extension = 2000; }
 	E_ForeignInt32Extension = &xxx_File_test_ext_proto_extDescs[0]
 )
-
-func init() {
-	proto.RegisterFile("test/ext.proto", xxx_File_test_ext_proto_rawdesc_gzipped)
-	proto.RegisterExtension(E_ForeignInt32Extension)
-}
-
 var xxx_File_test_ext_proto_rawdesc = []byte{
 	// 207 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x0e, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x65, 0x78, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
@@ -73,6 +67,8 @@ func xxx_File_test_ext_proto_init() {
 		LegacyExtensions:     xxx_File_test_ext_proto_extDescs,
 		ExtensionOutputTypes: extensionTypes,
 	}.Init()
+	proto.RegisterFile("test/ext.proto", xxx_File_test_ext_proto_rawdesc_gzipped)
+	proto.RegisterExtension(E_ForeignInt32Extension)
 	xxx_File_test_ext_proto_goTypes = nil
 	xxx_File_test_ext_proto_depIdxs = nil
 }

+ 72 - 76
internal/testprotos/test/test.pb.go

@@ -2005,82 +2005,6 @@ var (
 	// extend goproto.proto.test.TestAllExtensions { optional string nested_string_extension = 1003; }
 	E_TestNestedExtension_NestedStringExtension = &xxx_File_test_test_proto_extDescs[36]
 )
-
-func init() {
-	proto.RegisterFile("test/test.proto", xxx_File_test_test_proto_rawdesc_gzipped)
-	proto.RegisterEnum("goproto.proto.test.ForeignEnum", ForeignEnum_name, ForeignEnum_value)
-	proto.RegisterEnum("goproto.proto.test.TestReservedEnumFields", TestReservedEnumFields_name, TestReservedEnumFields_value)
-	proto.RegisterEnum("goproto.proto.test.TestAllTypes_NestedEnum", TestAllTypes_NestedEnum_name, TestAllTypes_NestedEnum_value)
-	proto.RegisterEnum("goproto.proto.test.TestDeprecatedMessage_DeprecatedEnum", TestDeprecatedMessage_DeprecatedEnum_name, TestDeprecatedMessage_DeprecatedEnum_value)
-	proto.RegisterType((*TestAllTypes)(nil), "goproto.proto.test.TestAllTypes")
-	proto.RegisterMapType((map[bool]bool)(nil), "goproto.proto.test.TestAllTypes.MapBoolBoolEntry")
-	proto.RegisterMapType((map[uint32]uint32)(nil), "goproto.proto.test.TestAllTypes.MapFixed32Fixed32Entry")
-	proto.RegisterMapType((map[uint64]uint64)(nil), "goproto.proto.test.TestAllTypes.MapFixed64Fixed64Entry")
-	proto.RegisterMapType((map[int32]float64)(nil), "goproto.proto.test.TestAllTypes.MapInt32DoubleEntry")
-	proto.RegisterMapType((map[int32]float32)(nil), "goproto.proto.test.TestAllTypes.MapInt32FloatEntry")
-	proto.RegisterMapType((map[int32]int32)(nil), "goproto.proto.test.TestAllTypes.MapInt32Int32Entry")
-	proto.RegisterMapType((map[int64]int64)(nil), "goproto.proto.test.TestAllTypes.MapInt64Int64Entry")
-	proto.RegisterMapType((map[int32]int32)(nil), "goproto.proto.test.TestAllTypes.MapSfixed32Sfixed32Entry")
-	proto.RegisterMapType((map[int64]int64)(nil), "goproto.proto.test.TestAllTypes.MapSfixed64Sfixed64Entry")
-	proto.RegisterMapType((map[int32]int32)(nil), "goproto.proto.test.TestAllTypes.MapSint32Sint32Entry")
-	proto.RegisterMapType((map[int64]int64)(nil), "goproto.proto.test.TestAllTypes.MapSint64Sint64Entry")
-	proto.RegisterMapType((map[string][]byte)(nil), "goproto.proto.test.TestAllTypes.MapStringBytesEntry")
-	proto.RegisterMapType((map[string]TestAllTypes_NestedEnum)(nil), "goproto.proto.test.TestAllTypes.MapStringNestedEnumEntry")
-	proto.RegisterMapType((map[string]*TestAllTypes_NestedMessage)(nil), "goproto.proto.test.TestAllTypes.MapStringNestedMessageEntry")
-	proto.RegisterMapType((map[string]string)(nil), "goproto.proto.test.TestAllTypes.MapStringStringEntry")
-	proto.RegisterMapType((map[uint32]uint32)(nil), "goproto.proto.test.TestAllTypes.MapUint32Uint32Entry")
-	proto.RegisterMapType((map[uint64]uint64)(nil), "goproto.proto.test.TestAllTypes.MapUint64Uint64Entry")
-	proto.RegisterType((*TestDeprecatedMessage)(nil), "goproto.proto.test.TestDeprecatedMessage")
-	proto.RegisterType((*ForeignMessage)(nil), "goproto.proto.test.ForeignMessage")
-	proto.RegisterType((*TestReservedFields)(nil), "goproto.proto.test.TestReservedFields")
-	proto.RegisterType((*TestAllExtensions)(nil), "goproto.proto.test.TestAllExtensions")
-	proto.RegisterType((*OptionalGroupExtension)(nil), "goproto.proto.test.OptionalGroup_extension")
-	proto.RegisterType((*RepeatedGroupExtension)(nil), "goproto.proto.test.RepeatedGroup_extension")
-	proto.RegisterType((*TestNestedExtension)(nil), "goproto.proto.test.TestNestedExtension")
-	proto.RegisterType((*FooRequest)(nil), "goproto.proto.test.FooRequest")
-	proto.RegisterType((*FooResponse)(nil), "goproto.proto.test.FooResponse")
-	proto.RegisterType((*TestAllTypes_NestedMessage)(nil), "goproto.proto.test.TestAllTypes.NestedMessage")
-	proto.RegisterType((*TestAllTypes_OptionalGroup)(nil), "goproto.proto.test.TestAllTypes.OptionalGroup")
-	proto.RegisterType((*TestAllTypes_RepeatedGroup)(nil), "goproto.proto.test.TestAllTypes.RepeatedGroup")
-	proto.RegisterExtension(E_OptionalInt32Extension)
-	proto.RegisterExtension(E_OptionalInt64Extension)
-	proto.RegisterExtension(E_OptionalUint32Extension)
-	proto.RegisterExtension(E_OptionalUint64Extension)
-	proto.RegisterExtension(E_OptionalSint32Extension)
-	proto.RegisterExtension(E_OptionalSint64Extension)
-	proto.RegisterExtension(E_OptionalFixed32Extension)
-	proto.RegisterExtension(E_OptionalFixed64Extension)
-	proto.RegisterExtension(E_OptionalSfixed32Extension)
-	proto.RegisterExtension(E_OptionalSfixed64Extension)
-	proto.RegisterExtension(E_OptionalFloatExtension)
-	proto.RegisterExtension(E_OptionalDoubleExtension)
-	proto.RegisterExtension(E_OptionalBoolExtension)
-	proto.RegisterExtension(E_OptionalStringExtension)
-	proto.RegisterExtension(E_OptionalBytesExtension)
-	proto.RegisterExtension(E_OptionalgroupExtension)
-	proto.RegisterExtension(E_OptionalNestedMessageExtension)
-	proto.RegisterExtension(E_OptionalNestedEnumExtension)
-	proto.RegisterExtension(E_RepeatedInt32Extension)
-	proto.RegisterExtension(E_RepeatedInt64Extension)
-	proto.RegisterExtension(E_RepeatedUint32Extension)
-	proto.RegisterExtension(E_RepeatedUint64Extension)
-	proto.RegisterExtension(E_RepeatedSint32Extension)
-	proto.RegisterExtension(E_RepeatedSint64Extension)
-	proto.RegisterExtension(E_RepeatedFixed32Extension)
-	proto.RegisterExtension(E_RepeatedFixed64Extension)
-	proto.RegisterExtension(E_RepeatedSfixed32Extension)
-	proto.RegisterExtension(E_RepeatedSfixed64Extension)
-	proto.RegisterExtension(E_RepeatedFloatExtension)
-	proto.RegisterExtension(E_RepeatedDoubleExtension)
-	proto.RegisterExtension(E_RepeatedBoolExtension)
-	proto.RegisterExtension(E_RepeatedStringExtension)
-	proto.RegisterExtension(E_RepeatedBytesExtension)
-	proto.RegisterExtension(E_RepeatedgroupExtension)
-	proto.RegisterExtension(E_RepeatedNestedMessageExtension)
-	proto.RegisterExtension(E_RepeatedNestedEnumExtension)
-	proto.RegisterExtension(E_TestNestedExtension_NestedStringExtension)
-}
-
 var xxx_File_test_test_proto_rawdesc = []byte{
 	// 12074 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x0f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74,
@@ -3000,6 +2924,78 @@ func xxx_File_test_test_proto_init() {
 		xxx_File_test_test_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_test_test_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("test/test.proto", xxx_File_test_test_proto_rawdesc_gzipped)
+	proto.RegisterEnum("goproto.proto.test.ForeignEnum", ForeignEnum_name, ForeignEnum_value)
+	proto.RegisterEnum("goproto.proto.test.TestReservedEnumFields", TestReservedEnumFields_name, TestReservedEnumFields_value)
+	proto.RegisterEnum("goproto.proto.test.TestAllTypes_NestedEnum", TestAllTypes_NestedEnum_name, TestAllTypes_NestedEnum_value)
+	proto.RegisterEnum("goproto.proto.test.TestDeprecatedMessage_DeprecatedEnum", TestDeprecatedMessage_DeprecatedEnum_name, TestDeprecatedMessage_DeprecatedEnum_value)
+	proto.RegisterType((*TestAllTypes)(nil), "goproto.proto.test.TestAllTypes")
+	proto.RegisterMapType((map[bool]bool)(nil), "goproto.proto.test.TestAllTypes.MapBoolBoolEntry")
+	proto.RegisterMapType((map[uint32]uint32)(nil), "goproto.proto.test.TestAllTypes.MapFixed32Fixed32Entry")
+	proto.RegisterMapType((map[uint64]uint64)(nil), "goproto.proto.test.TestAllTypes.MapFixed64Fixed64Entry")
+	proto.RegisterMapType((map[int32]float64)(nil), "goproto.proto.test.TestAllTypes.MapInt32DoubleEntry")
+	proto.RegisterMapType((map[int32]float32)(nil), "goproto.proto.test.TestAllTypes.MapInt32FloatEntry")
+	proto.RegisterMapType((map[int32]int32)(nil), "goproto.proto.test.TestAllTypes.MapInt32Int32Entry")
+	proto.RegisterMapType((map[int64]int64)(nil), "goproto.proto.test.TestAllTypes.MapInt64Int64Entry")
+	proto.RegisterMapType((map[int32]int32)(nil), "goproto.proto.test.TestAllTypes.MapSfixed32Sfixed32Entry")
+	proto.RegisterMapType((map[int64]int64)(nil), "goproto.proto.test.TestAllTypes.MapSfixed64Sfixed64Entry")
+	proto.RegisterMapType((map[int32]int32)(nil), "goproto.proto.test.TestAllTypes.MapSint32Sint32Entry")
+	proto.RegisterMapType((map[int64]int64)(nil), "goproto.proto.test.TestAllTypes.MapSint64Sint64Entry")
+	proto.RegisterMapType((map[string][]byte)(nil), "goproto.proto.test.TestAllTypes.MapStringBytesEntry")
+	proto.RegisterMapType((map[string]TestAllTypes_NestedEnum)(nil), "goproto.proto.test.TestAllTypes.MapStringNestedEnumEntry")
+	proto.RegisterMapType((map[string]*TestAllTypes_NestedMessage)(nil), "goproto.proto.test.TestAllTypes.MapStringNestedMessageEntry")
+	proto.RegisterMapType((map[string]string)(nil), "goproto.proto.test.TestAllTypes.MapStringStringEntry")
+	proto.RegisterMapType((map[uint32]uint32)(nil), "goproto.proto.test.TestAllTypes.MapUint32Uint32Entry")
+	proto.RegisterMapType((map[uint64]uint64)(nil), "goproto.proto.test.TestAllTypes.MapUint64Uint64Entry")
+	proto.RegisterType((*TestDeprecatedMessage)(nil), "goproto.proto.test.TestDeprecatedMessage")
+	proto.RegisterType((*ForeignMessage)(nil), "goproto.proto.test.ForeignMessage")
+	proto.RegisterType((*TestReservedFields)(nil), "goproto.proto.test.TestReservedFields")
+	proto.RegisterType((*TestAllExtensions)(nil), "goproto.proto.test.TestAllExtensions")
+	proto.RegisterType((*OptionalGroupExtension)(nil), "goproto.proto.test.OptionalGroup_extension")
+	proto.RegisterType((*RepeatedGroupExtension)(nil), "goproto.proto.test.RepeatedGroup_extension")
+	proto.RegisterType((*TestNestedExtension)(nil), "goproto.proto.test.TestNestedExtension")
+	proto.RegisterType((*FooRequest)(nil), "goproto.proto.test.FooRequest")
+	proto.RegisterType((*FooResponse)(nil), "goproto.proto.test.FooResponse")
+	proto.RegisterType((*TestAllTypes_NestedMessage)(nil), "goproto.proto.test.TestAllTypes.NestedMessage")
+	proto.RegisterType((*TestAllTypes_OptionalGroup)(nil), "goproto.proto.test.TestAllTypes.OptionalGroup")
+	proto.RegisterType((*TestAllTypes_RepeatedGroup)(nil), "goproto.proto.test.TestAllTypes.RepeatedGroup")
+	proto.RegisterExtension(E_OptionalInt32Extension)
+	proto.RegisterExtension(E_OptionalInt64Extension)
+	proto.RegisterExtension(E_OptionalUint32Extension)
+	proto.RegisterExtension(E_OptionalUint64Extension)
+	proto.RegisterExtension(E_OptionalSint32Extension)
+	proto.RegisterExtension(E_OptionalSint64Extension)
+	proto.RegisterExtension(E_OptionalFixed32Extension)
+	proto.RegisterExtension(E_OptionalFixed64Extension)
+	proto.RegisterExtension(E_OptionalSfixed32Extension)
+	proto.RegisterExtension(E_OptionalSfixed64Extension)
+	proto.RegisterExtension(E_OptionalFloatExtension)
+	proto.RegisterExtension(E_OptionalDoubleExtension)
+	proto.RegisterExtension(E_OptionalBoolExtension)
+	proto.RegisterExtension(E_OptionalStringExtension)
+	proto.RegisterExtension(E_OptionalBytesExtension)
+	proto.RegisterExtension(E_OptionalgroupExtension)
+	proto.RegisterExtension(E_OptionalNestedMessageExtension)
+	proto.RegisterExtension(E_OptionalNestedEnumExtension)
+	proto.RegisterExtension(E_RepeatedInt32Extension)
+	proto.RegisterExtension(E_RepeatedInt64Extension)
+	proto.RegisterExtension(E_RepeatedUint32Extension)
+	proto.RegisterExtension(E_RepeatedUint64Extension)
+	proto.RegisterExtension(E_RepeatedSint32Extension)
+	proto.RegisterExtension(E_RepeatedSint64Extension)
+	proto.RegisterExtension(E_RepeatedFixed32Extension)
+	proto.RegisterExtension(E_RepeatedFixed64Extension)
+	proto.RegisterExtension(E_RepeatedSfixed32Extension)
+	proto.RegisterExtension(E_RepeatedSfixed64Extension)
+	proto.RegisterExtension(E_RepeatedFloatExtension)
+	proto.RegisterExtension(E_RepeatedDoubleExtension)
+	proto.RegisterExtension(E_RepeatedBoolExtension)
+	proto.RegisterExtension(E_RepeatedStringExtension)
+	proto.RegisterExtension(E_RepeatedBytesExtension)
+	proto.RegisterExtension(E_RepeatedgroupExtension)
+	proto.RegisterExtension(E_RepeatedNestedMessageExtension)
+	proto.RegisterExtension(E_RepeatedNestedEnumExtension)
+	proto.RegisterExtension(E_TestNestedExtension_NestedStringExtension)
 	xxx_File_test_test_proto_goTypes = nil
 	xxx_File_test_test_proto_depIdxs = nil
 }

+ 3 - 6
internal/testprotos/test/test_import.pb.go

@@ -92,12 +92,6 @@ func (m *ImportMessage) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_ImportMessage proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("test/test_import.proto", xxx_File_test_test_import_proto_rawdesc_gzipped)
-	proto.RegisterEnum("goproto.proto.test.ImportEnum", ImportEnum_name, ImportEnum_value)
-	proto.RegisterType((*ImportMessage)(nil), "goproto.proto.test.ImportMessage")
-}
-
 var xxx_File_test_test_import_proto_rawdesc = []byte{
 	// 150 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x16, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x6d, 0x70, 0x6f,
@@ -144,6 +138,9 @@ func xxx_File_test_test_import_proto_init() {
 		xxx_File_test_test_import_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_test_test_import_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("test/test_import.proto", xxx_File_test_test_import_proto_rawdesc_gzipped)
+	proto.RegisterEnum("goproto.proto.test.ImportEnum", ImportEnum_name, ImportEnum_value)
+	proto.RegisterType((*ImportMessage)(nil), "goproto.proto.test.ImportMessage")
 	xxx_File_test_test_import_proto_goTypes = nil
 	xxx_File_test_test_import_proto_depIdxs = nil
 }

+ 2 - 5
internal/testprotos/test/test_public.pb.go

@@ -46,11 +46,6 @@ func (m *PublicImportMessage) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_PublicImportMessage proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("test/test_public.proto", xxx_File_test_test_public_proto_rawdesc_gzipped)
-	proto.RegisterType((*PublicImportMessage)(nil), "goproto.proto.test.PublicImportMessage")
-}
-
 var xxx_File_test_test_public_proto_rawdesc = []byte{
 	// 125 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x16, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c,
@@ -92,6 +87,8 @@ func xxx_File_test_test_public_proto_init() {
 		xxx_File_test_test_public_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_test_test_public_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("test/test_public.proto", xxx_File_test_test_public_proto_rawdesc_gzipped)
+	proto.RegisterType((*PublicImportMessage)(nil), "goproto.proto.test.PublicImportMessage")
 	xxx_File_test_test_public_proto_goTypes = nil
 	xxx_File_test_test_public_proto_depIdxs = nil
 }

+ 2 - 5
internal/testprotos/test/test_weak.pb.go

@@ -46,11 +46,6 @@ func (m *WeakImportMessage) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_WeakImportMessage proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("test/test_weak.proto", xxx_File_test_test_weak_proto_rawdesc_gzipped)
-	proto.RegisterType((*WeakImportMessage)(nil), "goproto.proto.test.WeakImportMessage")
-}
-
 var xxx_File_test_test_weak_proto_rawdesc = []byte{
 	// 121 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x14, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x77, 0x65, 0x61, 0x6b,
@@ -92,6 +87,8 @@ func xxx_File_test_test_weak_proto_init() {
 		xxx_File_test_test_weak_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_test_test_weak_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("test/test_weak.proto", xxx_File_test_test_weak_proto_rawdesc_gzipped)
+	proto.RegisterType((*WeakImportMessage)(nil), "goproto.proto.test.WeakImportMessage")
 	xxx_File_test_test_weak_proto_goTypes = nil
 	xxx_File_test_test_weak_proto_depIdxs = nil
 }

+ 14 - 18
reflect/protoregistry/testprotos/test.pb.go

@@ -379,24 +379,6 @@ var (
 	// extend testprotos.Message1 { optional string string_field = 23; }
 	E_Message4_StringField = &xxx_File_test_proto_extDescs[5]
 )
-
-func init() {
-	proto.RegisterFile("test.proto", xxx_File_test_proto_rawdesc_gzipped)
-	proto.RegisterEnum("testprotos.Enum1", Enum1_name, Enum1_value)
-	proto.RegisterEnum("testprotos.Enum2", Enum2_name, Enum2_value)
-	proto.RegisterEnum("testprotos.Enum3", Enum3_name, Enum3_value)
-	proto.RegisterType((*Message1)(nil), "testprotos.Message1")
-	proto.RegisterType((*Message2)(nil), "testprotos.Message2")
-	proto.RegisterType((*Message3)(nil), "testprotos.Message3")
-	proto.RegisterType((*Message4)(nil), "testprotos.Message4")
-	proto.RegisterExtension(E_StringField)
-	proto.RegisterExtension(E_EnumField)
-	proto.RegisterExtension(E_MessageField)
-	proto.RegisterExtension(E_Message4_MessageField)
-	proto.RegisterExtension(E_Message4_EnumField)
-	proto.RegisterExtension(E_Message4_StringField)
-}
-
 var xxx_File_test_proto_rawdesc = []byte{
 	// 653 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x74, 0x65,
@@ -493,6 +475,20 @@ func xxx_File_test_proto_init() {
 		xxx_File_test_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_test_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("test.proto", xxx_File_test_proto_rawdesc_gzipped)
+	proto.RegisterEnum("testprotos.Enum1", Enum1_name, Enum1_value)
+	proto.RegisterEnum("testprotos.Enum2", Enum2_name, Enum2_value)
+	proto.RegisterEnum("testprotos.Enum3", Enum3_name, Enum3_value)
+	proto.RegisterType((*Message1)(nil), "testprotos.Message1")
+	proto.RegisterType((*Message2)(nil), "testprotos.Message2")
+	proto.RegisterType((*Message3)(nil), "testprotos.Message3")
+	proto.RegisterType((*Message4)(nil), "testprotos.Message4")
+	proto.RegisterExtension(E_StringField)
+	proto.RegisterExtension(E_EnumField)
+	proto.RegisterExtension(E_MessageField)
+	proto.RegisterExtension(E_Message4_MessageField)
+	proto.RegisterExtension(E_Message4_EnumField)
+	proto.RegisterExtension(E_Message4_StringField)
 	xxx_File_test_proto_goTypes = nil
 	xxx_File_test_proto_depIdxs = nil
 }

+ 2 - 5
types/known/any.pb.go

@@ -173,11 +173,6 @@ func (m *Any) GetValue() []byte {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("google/protobuf/any.proto", xxx_File_google_protobuf_any_proto_rawdesc_gzipped)
-	proto.RegisterType((*Any)(nil), "google.protobuf.Any")
-}
-
 var xxx_File_google_protobuf_any_proto_rawdesc = []byte{
 	// 237 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
@@ -226,6 +221,8 @@ func xxx_File_google_protobuf_any_proto_init() {
 		xxx_File_google_protobuf_any_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_google_protobuf_any_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("google/protobuf/any.proto", xxx_File_google_protobuf_any_proto_rawdesc_gzipped)
+	proto.RegisterType((*Any)(nil), "google.protobuf.Any")
 	xxx_File_google_protobuf_any_proto_goTypes = nil
 	xxx_File_google_protobuf_any_proto_depIdxs = nil
 }

+ 4 - 7
types/known/api.pb.go

@@ -373,13 +373,6 @@ func (m *Mixin) GetRoot() string {
 	return ""
 }
 
-func init() {
-	proto.RegisterFile("google/protobuf/api.proto", xxx_File_google_protobuf_api_proto_rawdesc_gzipped)
-	proto.RegisterType((*Api)(nil), "google.protobuf.Api")
-	proto.RegisterType((*Method)(nil), "google.protobuf.Method")
-	proto.RegisterType((*Mixin)(nil), "google.protobuf.Mixin")
-}
-
 var xxx_File_google_protobuf_api_proto_rawdesc = []byte{
 	// 929 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
@@ -487,6 +480,10 @@ func xxx_File_google_protobuf_api_proto_init() {
 		xxx_File_google_protobuf_api_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_google_protobuf_api_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("google/protobuf/api.proto", xxx_File_google_protobuf_api_proto_rawdesc_gzipped)
+	proto.RegisterType((*Api)(nil), "google.protobuf.Api")
+	proto.RegisterType((*Method)(nil), "google.protobuf.Method")
+	proto.RegisterType((*Mixin)(nil), "google.protobuf.Mixin")
 	xxx_File_google_protobuf_api_proto_goTypes = nil
 	xxx_File_google_protobuf_api_proto_depIdxs = nil
 }

+ 2 - 5
types/known/duration.pb.go

@@ -133,11 +133,6 @@ func (m *Duration) GetNanos() int32 {
 	return 0
 }
 
-func init() {
-	proto.RegisterFile("google/protobuf/duration.proto", xxx_File_google_protobuf_duration_proto_rawdesc_gzipped)
-	proto.RegisterType((*Duration)(nil), "google.protobuf.Duration")
-}
-
 var xxx_File_google_protobuf_duration_proto_rawdesc = []byte{
 	// 255 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
@@ -187,6 +182,8 @@ func xxx_File_google_protobuf_duration_proto_init() {
 		xxx_File_google_protobuf_duration_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_google_protobuf_duration_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("google/protobuf/duration.proto", xxx_File_google_protobuf_duration_proto_rawdesc_gzipped)
+	proto.RegisterType((*Duration)(nil), "google.protobuf.Duration")
 	xxx_File_google_protobuf_duration_proto_goTypes = nil
 	xxx_File_google_protobuf_duration_proto_depIdxs = nil
 }

+ 2 - 5
types/known/empty.pb.go

@@ -57,11 +57,6 @@ func (m *Empty) XXX_DiscardUnknown() {
 
 var xxx_messageInfo_Empty proto.InternalMessageInfo
 
-func init() {
-	proto.RegisterFile("google/protobuf/empty.proto", xxx_File_google_protobuf_empty_proto_rawdesc_gzipped)
-	proto.RegisterType((*Empty)(nil), "google.protobuf.Empty")
-}
-
 var xxx_File_google_protobuf_empty_proto_rawdesc = []byte{
 	// 198 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
@@ -108,6 +103,8 @@ func xxx_File_google_protobuf_empty_proto_init() {
 		xxx_File_google_protobuf_empty_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_google_protobuf_empty_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("google/protobuf/empty.proto", xxx_File_google_protobuf_empty_proto_rawdesc_gzipped)
+	proto.RegisterType((*Empty)(nil), "google.protobuf.Empty")
 	xxx_File_google_protobuf_empty_proto_goTypes = nil
 	xxx_File_google_protobuf_empty_proto_depIdxs = nil
 }

+ 2 - 5
types/known/field_mask.pb.go

@@ -254,11 +254,6 @@ func (m *FieldMask) GetPaths() []string {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("google/protobuf/field_mask.proto", xxx_File_google_protobuf_field_mask_proto_rawdesc_gzipped)
-	proto.RegisterType((*FieldMask)(nil), "google.protobuf.FieldMask")
-}
-
 var xxx_File_google_protobuf_field_mask_proto_rawdesc = []byte{
 	// 233 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
@@ -307,6 +302,8 @@ func xxx_File_google_protobuf_field_mask_proto_init() {
 		xxx_File_google_protobuf_field_mask_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_google_protobuf_field_mask_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("google/protobuf/field_mask.proto", xxx_File_google_protobuf_field_mask_proto_rawdesc_gzipped)
+	proto.RegisterType((*FieldMask)(nil), "google.protobuf.FieldMask")
 	xxx_File_google_protobuf_field_mask_proto_goTypes = nil
 	xxx_File_google_protobuf_field_mask_proto_depIdxs = nil
 }

+ 2 - 5
types/known/source_context.pb.go

@@ -58,11 +58,6 @@ func (m *SourceContext) GetFileName() string {
 	return ""
 }
 
-func init() {
-	proto.RegisterFile("google/protobuf/source_context.proto", xxx_File_google_protobuf_source_context_proto_rawdesc_gzipped)
-	proto.RegisterType((*SourceContext)(nil), "google.protobuf.SourceContext")
-}
-
 var xxx_File_google_protobuf_source_context_proto_rawdesc = []byte{
 	// 249 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x24, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
@@ -112,6 +107,8 @@ func xxx_File_google_protobuf_source_context_proto_init() {
 		xxx_File_google_protobuf_source_context_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_google_protobuf_source_context_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("google/protobuf/source_context.proto", xxx_File_google_protobuf_source_context_proto_rawdesc_gzipped)
+	proto.RegisterType((*SourceContext)(nil), "google.protobuf.SourceContext")
 	xxx_File_google_protobuf_source_context_proto_goTypes = nil
 	xxx_File_google_protobuf_source_context_proto_depIdxs = nil
 }

+ 6 - 9
types/known/struct.pb.go

@@ -315,15 +315,6 @@ func (m *ListValue) GetValues() []*Value {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("google/protobuf/struct.proto", xxx_File_google_protobuf_struct_proto_rawdesc_gzipped)
-	proto.RegisterEnum("google.protobuf.NullValue", NullValue_name, NullValue_value)
-	proto.RegisterType((*Struct)(nil), "google.protobuf.Struct")
-	proto.RegisterMapType((map[string]*Value)(nil), "google.protobuf.Struct.FieldsEntry")
-	proto.RegisterType((*Value)(nil), "google.protobuf.Value")
-	proto.RegisterType((*ListValue)(nil), "google.protobuf.ListValue")
-}
-
 var xxx_File_google_protobuf_struct_proto_rawdesc = []byte{
 	// 745 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
@@ -417,6 +408,12 @@ func xxx_File_google_protobuf_struct_proto_init() {
 		xxx_File_google_protobuf_struct_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_google_protobuf_struct_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("google/protobuf/struct.proto", xxx_File_google_protobuf_struct_proto_rawdesc_gzipped)
+	proto.RegisterEnum("google.protobuf.NullValue", NullValue_name, NullValue_value)
+	proto.RegisterType((*Struct)(nil), "google.protobuf.Struct")
+	proto.RegisterMapType((map[string]*Value)(nil), "google.protobuf.Struct.FieldsEntry")
+	proto.RegisterType((*Value)(nil), "google.protobuf.Value")
+	proto.RegisterType((*ListValue)(nil), "google.protobuf.ListValue")
 	xxx_File_google_protobuf_struct_proto_goTypes = nil
 	xxx_File_google_protobuf_struct_proto_depIdxs = nil
 }

+ 2 - 5
types/known/timestamp.pb.go

@@ -153,11 +153,6 @@ func (m *Timestamp) GetNanos() int32 {
 	return 0
 }
 
-func init() {
-	proto.RegisterFile("google/protobuf/timestamp.proto", xxx_File_google_protobuf_timestamp_proto_rawdesc_gzipped)
-	proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp")
-}
-
 var xxx_File_google_protobuf_timestamp_proto_rawdesc = []byte{
 	// 258 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
@@ -208,6 +203,8 @@ func xxx_File_google_protobuf_timestamp_proto_init() {
 		xxx_File_google_protobuf_timestamp_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_google_protobuf_timestamp_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("google/protobuf/timestamp.proto", xxx_File_google_protobuf_timestamp_proto_rawdesc_gzipped)
+	proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp")
 	xxx_File_google_protobuf_timestamp_proto_goTypes = nil
 	xxx_File_google_protobuf_timestamp_proto_depIdxs = nil
 }

+ 9 - 12
types/known/type.pb.go

@@ -628,18 +628,6 @@ func (m *Option) GetValue() *Any {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("google/protobuf/type.proto", xxx_File_google_protobuf_type_proto_rawdesc_gzipped)
-	proto.RegisterEnum("google.protobuf.Syntax", Syntax_name, Syntax_value)
-	proto.RegisterEnum("google.protobuf.Field_Kind", Field_Kind_name, Field_Kind_value)
-	proto.RegisterEnum("google.protobuf.Field_Cardinality", Field_Cardinality_name, Field_Cardinality_value)
-	proto.RegisterType((*Type)(nil), "google.protobuf.Type")
-	proto.RegisterType((*Field)(nil), "google.protobuf.Field")
-	proto.RegisterType((*Enum)(nil), "google.protobuf.Enum")
-	proto.RegisterType((*EnumValue)(nil), "google.protobuf.EnumValue")
-	proto.RegisterType((*Option)(nil), "google.protobuf.Option")
-}
-
 var xxx_File_google_protobuf_type_proto_rawdesc = []byte{
 	// 1835 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1a, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
@@ -815,6 +803,15 @@ func xxx_File_google_protobuf_type_proto_init() {
 		xxx_File_google_protobuf_type_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_google_protobuf_type_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("google/protobuf/type.proto", xxx_File_google_protobuf_type_proto_rawdesc_gzipped)
+	proto.RegisterEnum("google.protobuf.Syntax", Syntax_name, Syntax_value)
+	proto.RegisterEnum("google.protobuf.Field_Kind", Field_Kind_name, Field_Kind_value)
+	proto.RegisterEnum("google.protobuf.Field_Cardinality", Field_Cardinality_name, Field_Cardinality_value)
+	proto.RegisterType((*Type)(nil), "google.protobuf.Type")
+	proto.RegisterType((*Field)(nil), "google.protobuf.Field")
+	proto.RegisterType((*Enum)(nil), "google.protobuf.Enum")
+	proto.RegisterType((*EnumValue)(nil), "google.protobuf.EnumValue")
+	proto.RegisterType((*Option)(nil), "google.protobuf.Option")
 	xxx_File_google_protobuf_type_proto_goTypes = nil
 	xxx_File_google_protobuf_type_proto_depIdxs = nil
 }

+ 10 - 13
types/known/wrappers.pb.go

@@ -460,19 +460,6 @@ func (m *BytesValue) GetValue() []byte {
 	return nil
 }
 
-func init() {
-	proto.RegisterFile("google/protobuf/wrappers.proto", xxx_File_google_protobuf_wrappers_proto_rawdesc_gzipped)
-	proto.RegisterType((*DoubleValue)(nil), "google.protobuf.DoubleValue")
-	proto.RegisterType((*FloatValue)(nil), "google.protobuf.FloatValue")
-	proto.RegisterType((*Int64Value)(nil), "google.protobuf.Int64Value")
-	proto.RegisterType((*UInt64Value)(nil), "google.protobuf.UInt64Value")
-	proto.RegisterType((*Int32Value)(nil), "google.protobuf.Int32Value")
-	proto.RegisterType((*UInt32Value)(nil), "google.protobuf.UInt32Value")
-	proto.RegisterType((*BoolValue)(nil), "google.protobuf.BoolValue")
-	proto.RegisterType((*StringValue)(nil), "google.protobuf.StringValue")
-	proto.RegisterType((*BytesValue)(nil), "google.protobuf.BytesValue")
-}
-
 var xxx_File_google_protobuf_wrappers_proto_rawdesc = []byte{
 	// 522 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
@@ -547,6 +534,16 @@ func xxx_File_google_protobuf_wrappers_proto_init() {
 		xxx_File_google_protobuf_wrappers_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_google_protobuf_wrappers_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("google/protobuf/wrappers.proto", xxx_File_google_protobuf_wrappers_proto_rawdesc_gzipped)
+	proto.RegisterType((*DoubleValue)(nil), "google.protobuf.DoubleValue")
+	proto.RegisterType((*FloatValue)(nil), "google.protobuf.FloatValue")
+	proto.RegisterType((*Int64Value)(nil), "google.protobuf.Int64Value")
+	proto.RegisterType((*UInt64Value)(nil), "google.protobuf.UInt64Value")
+	proto.RegisterType((*Int32Value)(nil), "google.protobuf.Int32Value")
+	proto.RegisterType((*UInt32Value)(nil), "google.protobuf.UInt32Value")
+	proto.RegisterType((*BoolValue)(nil), "google.protobuf.BoolValue")
+	proto.RegisterType((*StringValue)(nil), "google.protobuf.StringValue")
+	proto.RegisterType((*BytesValue)(nil), "google.protobuf.BytesValue")
 	xxx_File_google_protobuf_wrappers_proto_goTypes = nil
 	xxx_File_google_protobuf_wrappers_proto_depIdxs = nil
 }

+ 5 - 8
types/plugin/plugin.pb.go

@@ -341,14 +341,6 @@ func (m *CodeGeneratorResponse_File) GetContent() string {
 	return ""
 }
 
-func init() {
-	proto.RegisterFile("google/protobuf/compiler/plugin.proto", xxx_File_google_protobuf_compiler_plugin_proto_rawdesc_gzipped)
-	proto.RegisterType((*Version)(nil), "google.protobuf.compiler.Version")
-	proto.RegisterType((*CodeGeneratorRequest)(nil), "google.protobuf.compiler.CodeGeneratorRequest")
-	proto.RegisterType((*CodeGeneratorResponse)(nil), "google.protobuf.compiler.CodeGeneratorResponse")
-	proto.RegisterType((*CodeGeneratorResponse_File)(nil), "google.protobuf.compiler.CodeGeneratorResponse.File")
-}
-
 var xxx_File_google_protobuf_compiler_plugin_proto_rawdesc = []byte{
 	// 764 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x25, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
@@ -438,6 +430,11 @@ func xxx_File_google_protobuf_compiler_plugin_proto_init() {
 		xxx_File_google_protobuf_compiler_plugin_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_google_protobuf_compiler_plugin_proto_messageTypes[i].PBType = mt
 	}
+	proto.RegisterFile("google/protobuf/compiler/plugin.proto", xxx_File_google_protobuf_compiler_plugin_proto_rawdesc_gzipped)
+	proto.RegisterType((*Version)(nil), "google.protobuf.compiler.Version")
+	proto.RegisterType((*CodeGeneratorRequest)(nil), "google.protobuf.compiler.CodeGeneratorRequest")
+	proto.RegisterType((*CodeGeneratorResponse)(nil), "google.protobuf.compiler.CodeGeneratorResponse")
+	proto.RegisterType((*CodeGeneratorResponse_File)(nil), "google.protobuf.compiler.CodeGeneratorResponse.File")
 	xxx_File_google_protobuf_compiler_plugin_proto_goTypes = nil
 	xxx_File_google_protobuf_compiler_plugin_proto_depIdxs = nil
 }