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>
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
index 876f17e..48974c0 100644
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
+++ b/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
@@ -9,10 +9,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
index 4b45691..240f089 100644
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
+++ b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
@@ -82,12 +82,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go
index 70ecbc9..fc9cb45 100644
--- a/cmd/protoc-gen-go/internal_gengo/main.go
+++ b/cmd/protoc-gen-go/internal_gengo/main.go
@@ -132,7 +132,6 @@
 	}
 	genExtensions(gen, g, f)
 
-	genInitFunction(gen, g, f)
 	genFileDescriptor(gen, g, f)
 	genReflectFileDescriptor(gen, g, f)
 
@@ -775,15 +774,14 @@
 	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 @@
 	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.
diff --git a/cmd/protoc-gen-go/internal_gengo/reflect.go b/cmd/protoc-gen-go/internal_gengo/reflect.go
index 7f2d25f..c2f429e 100644
--- a/cmd/protoc-gen-go/internal_gengo/reflect.go
+++ b/cmd/protoc-gen-go/internal_gengo/reflect.go
@@ -207,6 +207,8 @@
 		}
 	}
 
+	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("}")
diff --git a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
index 139bdaa..e2d071c 100644
--- a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
+++ b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
@@ -100,12 +100,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/comments/comments.pb.go b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
index 6f1d23e..d159b09 100644
--- a/cmd/protoc-gen-go/testdata/comments/comments.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
@@ -280,16 +280,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
index 442e208..ffee4cb 100644
--- a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
@@ -87,12 +87,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
index b18d32d..3d15a81 100644
--- a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
@@ -111,12 +111,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
index 2d08e1c..80459cb 100644
--- a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
@@ -874,64 +874,6 @@
 	// 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
index 9019b87..507b395 100644
--- a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
@@ -54,11 +54,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
index bc1aac9..5975879 100644
--- a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
@@ -456,47 +456,6 @@
 	// 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
index d42049a..02d8712 100644
--- a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
+++ b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
@@ -314,12 +314,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/import_public/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/a.pb.go
index 402131b..ceb4196 100644
--- a/cmd/protoc-gen-go/testdata/import_public/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/a.pb.go
@@ -114,11 +114,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/import_public/b.pb.go b/cmd/protoc-gen-go/testdata/import_public/b.pb.go
index 3cd1d46..56f9a72 100644
--- a/cmd/protoc-gen-go/testdata/import_public/b.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/b.pb.go
@@ -63,11 +63,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
index 0397983..bad05bc 100644
--- a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
@@ -386,17 +386,6 @@
 	// 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
index 81c15f1..28e3938 100644
--- a/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
@@ -46,11 +46,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
index daf8aea..a467e7d 100644
--- a/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
@@ -46,11 +46,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go b/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
index 28834f7..1fe71ef 100644
--- a/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
@@ -46,11 +46,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
index bcbf15f..167c0c9 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
@@ -122,13 +122,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
index bd02efc..102318c 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
@@ -46,11 +46,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
index 81c27b8..f23dce0 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
@@ -46,11 +46,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
index 339a836..3febc09 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
@@ -46,11 +46,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
index 021c341..924fc1c 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
@@ -46,11 +46,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
index 9d65402..02b89ba 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
@@ -46,11 +46,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
index e422585..e3117b5 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
@@ -55,11 +55,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
index ca8539a..99641a3 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
@@ -55,11 +55,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
index 94e725b..c51a54d 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
@@ -90,11 +90,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
index e700643..f069b11 100644
--- a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
+++ b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
@@ -80,11 +80,6 @@
 	}
 }
 
-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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
index e77bef4..cf2f164 100644
--- a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
+++ b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
@@ -110,12 +110,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
index 958b1d8..ecfed3c 100644
--- a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
@@ -394,18 +394,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
index 7d03b09..4806de3 100644
--- a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
@@ -1331,20 +1331,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
index 4870f39..47c5214 100644
--- a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
@@ -142,13 +142,6 @@
 
 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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
index 759bfb8..90eb7fa 100644
--- a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
@@ -62,11 +62,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
index 30b1304..68c890b 100644
--- a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
@@ -47,11 +47,6 @@
 	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 @@
 		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
 }
diff --git a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
index d7aa218..b4054cd 100644
--- a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
@@ -410,16 +410,6 @@
 
 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 @@
 		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
 }
diff --git a/encoding/testprotos/pb2/test.pb.go b/encoding/testprotos/pb2/test.pb.go
index b3e9cfd..3292ea2 100644
--- a/encoding/testprotos/pb2/test.pb.go
+++ b/encoding/testprotos/pb2/test.pb.go
@@ -1659,52 +1659,6 @@
 	// 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 @@
 		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
 }
diff --git a/encoding/testprotos/pb3/test.pb.go b/encoding/testprotos/pb3/test.pb.go
index 00d596a..9372908 100644
--- a/encoding/testprotos/pb3/test.pb.go
+++ b/encoding/testprotos/pb3/test.pb.go
@@ -623,24 +623,6 @@
 	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 @@
 		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
 }
diff --git a/internal/testprotos/conformance/conformance.pb.go b/internal/testprotos/conformance/conformance.pb.go
index dab5b06..e70227d 100644
--- a/internal/testprotos/conformance/conformance.pb.go
+++ b/internal/testprotos/conformance/conformance.pb.go
@@ -569,16 +569,6 @@
 	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 @@
 		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
 }
diff --git a/internal/testprotos/legacy/legacy.pb.go b/internal/testprotos/legacy/legacy.pb.go
index 670a8b4..5940e58 100644
--- a/internal/testprotos/legacy/legacy.pb.go
+++ b/internal/testprotos/legacy/legacy.pb.go
@@ -154,11 +154,6 @@
 	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 @@
 		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
 }
diff --git a/internal/testprotos/test/ext.pb.go b/internal/testprotos/test/ext.pb.go
index f52447d..0cb9ecf 100644
--- a/internal/testprotos/test/ext.pb.go
+++ b/internal/testprotos/test/ext.pb.go
@@ -23,12 +23,6 @@
 	// 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 @@
 		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
 }
diff --git a/internal/testprotos/test/test.pb.go b/internal/testprotos/test/test.pb.go
index e6b9c88..fe48501 100644
--- a/internal/testprotos/test/test.pb.go
+++ b/internal/testprotos/test/test.pb.go
@@ -2005,82 +2005,6 @@
 	// 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 @@
 		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
 }
diff --git a/internal/testprotos/test/test_import.pb.go b/internal/testprotos/test/test_import.pb.go
index 2b7ad1f..82cadcd 100644
--- a/internal/testprotos/test/test_import.pb.go
+++ b/internal/testprotos/test/test_import.pb.go
@@ -92,12 +92,6 @@
 
 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 @@
 		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
 }
diff --git a/internal/testprotos/test/test_public.pb.go b/internal/testprotos/test/test_public.pb.go
index 2be4785..6e5494a 100644
--- a/internal/testprotos/test/test_public.pb.go
+++ b/internal/testprotos/test/test_public.pb.go
@@ -46,11 +46,6 @@
 
 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 @@
 		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
 }
diff --git a/internal/testprotos/test/test_weak.pb.go b/internal/testprotos/test/test_weak.pb.go
index 54a9f44..ce220c2 100644
--- a/internal/testprotos/test/test_weak.pb.go
+++ b/internal/testprotos/test/test_weak.pb.go
@@ -46,11 +46,6 @@
 
 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 @@
 		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
 }
diff --git a/reflect/protoregistry/testprotos/test.pb.go b/reflect/protoregistry/testprotos/test.pb.go
index ff7c7ef..43e6db2 100644
--- a/reflect/protoregistry/testprotos/test.pb.go
+++ b/reflect/protoregistry/testprotos/test.pb.go
@@ -379,24 +379,6 @@
 	// 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 @@
 		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
 }
diff --git a/types/known/any.pb.go b/types/known/any.pb.go
index b1a3ac5..c175276 100644
--- a/types/known/any.pb.go
+++ b/types/known/any.pb.go
@@ -173,11 +173,6 @@
 	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 @@
 		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
 }
diff --git a/types/known/api.pb.go b/types/known/api.pb.go
index 5505165..ac69c8f 100644
--- a/types/known/api.pb.go
+++ b/types/known/api.pb.go
@@ -373,13 +373,6 @@
 	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 @@
 		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
 }
diff --git a/types/known/duration.pb.go b/types/known/duration.pb.go
index 8fc3702..dc4b761 100644
--- a/types/known/duration.pb.go
+++ b/types/known/duration.pb.go
@@ -133,11 +133,6 @@
 	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 @@
 		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
 }
diff --git a/types/known/empty.pb.go b/types/known/empty.pb.go
index 021ee95..1877968 100644
--- a/types/known/empty.pb.go
+++ b/types/known/empty.pb.go
@@ -57,11 +57,6 @@
 
 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 @@
 		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
 }
diff --git a/types/known/field_mask.pb.go b/types/known/field_mask.pb.go
index 9fee8aa..ad2aa2e 100644
--- a/types/known/field_mask.pb.go
+++ b/types/known/field_mask.pb.go
@@ -254,11 +254,6 @@
 	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 @@
 		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
 }
diff --git a/types/known/source_context.pb.go b/types/known/source_context.pb.go
index 292ef04..1bbcd54 100644
--- a/types/known/source_context.pb.go
+++ b/types/known/source_context.pb.go
@@ -58,11 +58,6 @@
 	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 @@
 		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
 }
diff --git a/types/known/struct.pb.go b/types/known/struct.pb.go
index c064f59..9fc8f8f 100644
--- a/types/known/struct.pb.go
+++ b/types/known/struct.pb.go
@@ -315,15 +315,6 @@
 	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 @@
 		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
 }
diff --git a/types/known/timestamp.pb.go b/types/known/timestamp.pb.go
index 422dfb5..3251172 100644
--- a/types/known/timestamp.pb.go
+++ b/types/known/timestamp.pb.go
@@ -153,11 +153,6 @@
 	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 @@
 		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
 }
diff --git a/types/known/type.pb.go b/types/known/type.pb.go
index 8e76708..b183a9b 100644
--- a/types/known/type.pb.go
+++ b/types/known/type.pb.go
@@ -628,18 +628,6 @@
 	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 @@
 		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
 }
diff --git a/types/known/wrappers.pb.go b/types/known/wrappers.pb.go
index dcf9780..7dc0c1c 100644
--- a/types/known/wrappers.pb.go
+++ b/types/known/wrappers.pb.go
@@ -460,19 +460,6 @@
 	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 @@
 		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
 }
diff --git a/types/plugin/plugin.pb.go b/types/plugin/plugin.pb.go
index ab9ae91..2dbae9d 100644
--- a/types/plugin/plugin.pb.go
+++ b/types/plugin/plugin.pb.go
@@ -341,14 +341,6 @@
 	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 @@
 		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
 }