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/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
 }