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