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