cmd/protoc-gen-go: change some arrays to slices to save bytes

Using arrays in the generated reflection information adds unnecessary
eq and hash functions being added to the package. Change to slices
to reduce bloat.

Change-Id: I1a4f6d59021644d93dd6c24679b9233141e89a75
Reviewed-on: https://go-review.googlesource.com/c/164640
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/cmd/protoc-gen-go/internal_gengo/reflect.go b/cmd/protoc-gen-go/internal_gengo/reflect.go
index ee7bd61..56a026d 100644
--- a/cmd/protoc-gen-go/internal_gengo/reflect.go
+++ b/cmd/protoc-gen-go/internal_gengo/reflect.go
@@ -54,10 +54,10 @@
 	g.P()
 
 	if len(f.allEnums) > 0 {
-		g.P("var ", enumTypesVarName(f), " [", len(f.allEnums), "]", protoreflectPackage.Ident("EnumType"))
+		g.P("var ", enumTypesVarName(f), " = make([]", protoreflectPackage.Ident("EnumType"), ",", len(f.allEnums), ")")
 	}
 	if len(f.allMessages) > 0 {
-		g.P("var ", messageTypesVarName(f), " [", len(f.allMessages), "]", protoimplPackage.Ident("MessageType"))
+		g.P("var ", messageTypesVarName(f), " = make([]", protoimplPackage.Ident("MessageType"), ",", len(f.allMessages), ")")
 	}
 
 	// Generate a unique list of Go types for all declarations and dependencies,
@@ -153,10 +153,10 @@
 
 	g.P("func init() {")
 	if len(f.allMessages) > 0 {
-		g.P("var messageTypes [", len(f.allMessages), "]", protoreflectPackage.Ident("MessageType"))
+		g.P("messageTypes := make([]", protoreflectPackage.Ident("MessageType"), ",", len(f.allMessages), ")")
 	}
 	if len(f.allExtensions) > 0 {
-		g.P("var extensionTypes [", len(f.allExtensions), "]", protoreflectPackage.Ident("ExtensionType"))
+		g.P("extensionTypes := make([]", protoreflectPackage.Ident("ExtensionType"), ",", len(f.allExtensions), ")")
 	}
 
 	g.P(f.GoDescriptorIdent, " = ", protoimplPackage.Ident("FileBuilder"), "{")
@@ -164,20 +164,20 @@
 	g.P("GoTypes: ", goTypesVarName(f), ",")
 	g.P("DependencyIndexes: ", depIdxsVarName(f), ",")
 	if len(f.allEnums) > 0 {
-		g.P("EnumOutputTypes: ", enumTypesVarName(f), "[:],")
+		g.P("EnumOutputTypes: ", enumTypesVarName(f), ",")
 	}
 	if len(f.allMessages) > 0 {
-		g.P("MessageOutputTypes: messageTypes[:],")
+		g.P("MessageOutputTypes: messageTypes,")
 	}
 	if len(f.allExtensions) > 0 {
-		g.P("ExtensionOutputTypes: extensionTypes[:],")
+		g.P("ExtensionOutputTypes: extensionTypes,")
 	}
 	g.P("}.Init()")
 
 	// Copy the local list of message types into the global array.
 	if len(f.allMessages) > 0 {
 		g.P("messageGoTypes := ", goTypesVarName(f), "[", len(f.allEnums), ":][:", len(f.allMessages), "]")
-		g.P("for i, mt := range messageTypes[:] {")
+		g.P("for i, mt := range messageTypes {")
 		g.P(messageTypesVarName(f), "[i].GoType = ", reflectPackage.Ident("TypeOf"), "(messageGoTypes[i])")
 		g.P(messageTypesVarName(f), "[i].PBType = mt")
 		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 fe40d90..2a8a178 100644
--- a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
+++ b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
@@ -136,8 +136,8 @@
 
 var File_annotations_annotations_proto protoreflect.FileDescriptor
 
-var xxx_File_annotations_annotations_proto_enumTypes [1]protoreflect.EnumType
-var xxx_File_annotations_annotations_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_annotations_annotations_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var xxx_File_annotations_annotations_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_annotations_annotations_proto_goTypes = []interface{}{
 	(AnnotationsTestEnum)(0),       // 0: goproto.protoc.annotations.AnnotationsTestEnum
 	(*AnnotationsTestMessage)(nil), // 1: goproto.protoc.annotations.AnnotationsTestMessage
@@ -145,16 +145,16 @@
 var xxx_File_annotations_annotations_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_annotations_annotations_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_annotations_annotations_proto_rawdesc,
 		GoTypes:            xxx_File_annotations_annotations_proto_goTypes,
 		DependencyIndexes:  xxx_File_annotations_annotations_proto_depIdxs,
-		EnumOutputTypes:    xxx_File_annotations_annotations_proto_enumTypes[:],
-		MessageOutputTypes: messageTypes[:],
+		EnumOutputTypes:    xxx_File_annotations_annotations_proto_enumTypes,
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_annotations_annotations_proto_goTypes[1:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_annotations_annotations_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_annotations_annotations_proto_messageTypes[i].PBType = mt
 	}
diff --git a/cmd/protoc-gen-go/testdata/comments/comments.pb.go b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
index dfa715a..2c749f9 100644
--- a/cmd/protoc-gen-go/testdata/comments/comments.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
@@ -312,7 +312,7 @@
 
 var File_comments_comments_proto protoreflect.FileDescriptor
 
-var xxx_File_comments_comments_proto_messageTypes [6]protoimpl.MessageType
+var xxx_File_comments_comments_proto_messageTypes = make([]protoimpl.MessageType, 6)
 var xxx_File_comments_comments_proto_goTypes = []interface{}{
 	(*Message1)(nil),           // 0: goproto.protoc.comments.Message1
 	(*Message2)(nil),           // 1: goproto.protoc.comments.Message2
@@ -324,15 +324,15 @@
 var xxx_File_comments_comments_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [6]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 6)
 	File_comments_comments_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_comments_comments_proto_rawdesc,
 		GoTypes:            xxx_File_comments_comments_proto_goTypes,
 		DependencyIndexes:  xxx_File_comments_comments_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_comments_comments_proto_goTypes[0:][:6]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_comments_comments_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_comments_comments_proto_messageTypes[i].PBType = mt
 	}
diff --git a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
index 1f74a58..7bd74fb 100644
--- a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
@@ -121,8 +121,8 @@
 
 var File_comments_deprecated_proto protoreflect.FileDescriptor
 
-var xxx_File_comments_deprecated_proto_enumTypes [1]protoreflect.EnumType
-var xxx_File_comments_deprecated_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_comments_deprecated_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var xxx_File_comments_deprecated_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_comments_deprecated_proto_goTypes = []interface{}{
 	(DeprecatedEnum)(0),       // 0: goproto.protoc.comments.DeprecatedEnum
 	(*DeprecatedMessage)(nil), // 1: goproto.protoc.comments.DeprecatedMessage
@@ -130,16 +130,16 @@
 var xxx_File_comments_deprecated_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_comments_deprecated_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_comments_deprecated_proto_rawdesc,
 		GoTypes:            xxx_File_comments_deprecated_proto_goTypes,
 		DependencyIndexes:  xxx_File_comments_deprecated_proto_depIdxs,
-		EnumOutputTypes:    xxx_File_comments_deprecated_proto_enumTypes[:],
-		MessageOutputTypes: messageTypes[:],
+		EnumOutputTypes:    xxx_File_comments_deprecated_proto_enumTypes,
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_comments_deprecated_proto_goTypes[1:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_comments_deprecated_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_comments_deprecated_proto_messageTypes[i].PBType = mt
 	}
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 6d3a2c3..b44d4e2 100644
--- a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
@@ -143,7 +143,7 @@
 
 var File_extensions_base_base_proto protoreflect.FileDescriptor
 
-var xxx_File_extensions_base_base_proto_messageTypes [2]protoimpl.MessageType
+var xxx_File_extensions_base_base_proto_messageTypes = make([]protoimpl.MessageType, 2)
 var xxx_File_extensions_base_base_proto_goTypes = []interface{}{
 	(*BaseMessage)(nil),                 // 0: goproto.protoc.extension.base.BaseMessage
 	(*MessageSetWireFormatMessage)(nil), // 1: goproto.protoc.extension.base.MessageSetWireFormatMessage
@@ -151,15 +151,15 @@
 var xxx_File_extensions_base_base_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [2]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 2)
 	File_extensions_base_base_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_extensions_base_base_proto_rawdesc,
 		GoTypes:            xxx_File_extensions_base_base_proto_goTypes,
 		DependencyIndexes:  xxx_File_extensions_base_base_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_extensions_base_base_proto_goTypes[0:][:2]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_extensions_base_base_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_extensions_base_base_proto_messageTypes[i].PBType = mt
 	}
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 97141c6..eb81aa8 100644
--- a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
@@ -1151,8 +1151,8 @@
 
 var File_extensions_ext_ext_proto protoreflect.FileDescriptor
 
-var xxx_File_extensions_ext_ext_proto_enumTypes [1]protoreflect.EnumType
-var xxx_File_extensions_ext_ext_proto_messageTypes [8]protoimpl.MessageType
+var xxx_File_extensions_ext_ext_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var xxx_File_extensions_ext_ext_proto_messageTypes = make([]protoimpl.MessageType, 8)
 var xxx_File_extensions_ext_ext_proto_goTypes = []interface{}{
 	(Enum)(0),                             // 0: goproto.protoc.extension.ext.Enum
 	(*Message)(nil),                       // 1: goproto.protoc.extension.ext.Message
@@ -1227,18 +1227,18 @@
 }
 
 func init() {
-	var messageTypes [8]protoreflect.MessageType
-	var extensionTypes [44]protoreflect.ExtensionType
+	messageTypes := make([]protoreflect.MessageType, 8)
+	extensionTypes := make([]protoreflect.ExtensionType, 44)
 	File_extensions_ext_ext_proto = protoimpl.FileBuilder{
 		RawDescriptor:        xxx_File_extensions_ext_ext_proto_rawdesc,
 		GoTypes:              xxx_File_extensions_ext_ext_proto_goTypes,
 		DependencyIndexes:    xxx_File_extensions_ext_ext_proto_depIdxs,
-		EnumOutputTypes:      xxx_File_extensions_ext_ext_proto_enumTypes[:],
-		MessageOutputTypes:   messageTypes[:],
-		ExtensionOutputTypes: extensionTypes[:],
+		EnumOutputTypes:      xxx_File_extensions_ext_ext_proto_enumTypes,
+		MessageOutputTypes:   messageTypes,
+		ExtensionOutputTypes: extensionTypes,
 	}.Init()
 	messageGoTypes := xxx_File_extensions_ext_ext_proto_goTypes[1:][:8]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_extensions_ext_ext_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_extensions_ext_ext_proto_messageTypes[i].PBType = mt
 	}
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 4f88fdf..a10a43d 100644
--- a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
@@ -85,22 +85,22 @@
 
 var File_extensions_extra_extra_proto protoreflect.FileDescriptor
 
-var xxx_File_extensions_extra_extra_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_extensions_extra_extra_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_extensions_extra_extra_proto_goTypes = []interface{}{
 	(*ExtraMessage)(nil), // 0: goproto.protoc.extension.extra.ExtraMessage
 }
 var xxx_File_extensions_extra_extra_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_extensions_extra_extra_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_extensions_extra_extra_proto_rawdesc,
 		GoTypes:            xxx_File_extensions_extra_extra_proto_goTypes,
 		DependencyIndexes:  xxx_File_extensions_extra_extra_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_extensions_extra_extra_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_extensions_extra_extra_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_extensions_extra_extra_proto_messageTypes[i].PBType = mt
 	}
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 f1b831b..010c9c2 100644
--- a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
@@ -642,8 +642,8 @@
 
 var File_extensions_proto3_ext3_proto protoreflect.FileDescriptor
 
-var xxx_File_extensions_proto3_ext3_proto_enumTypes [1]protoreflect.EnumType
-var xxx_File_extensions_proto3_ext3_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_extensions_proto3_ext3_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var xxx_File_extensions_proto3_ext3_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_extensions_proto3_ext3_proto_goTypes = []interface{}{
 	(Enum)(0),                         // 0: goproto.protoc.extension.proto3.Enum
 	(*Message)(nil),                   // 1: goproto.protoc.extension.proto3.Message
@@ -691,18 +691,18 @@
 }
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
-	var extensionTypes [34]protoreflect.ExtensionType
+	messageTypes := make([]protoreflect.MessageType, 1)
+	extensionTypes := make([]protoreflect.ExtensionType, 34)
 	File_extensions_proto3_ext3_proto = protoimpl.FileBuilder{
 		RawDescriptor:        xxx_File_extensions_proto3_ext3_proto_rawdesc,
 		GoTypes:              xxx_File_extensions_proto3_ext3_proto_goTypes,
 		DependencyIndexes:    xxx_File_extensions_proto3_ext3_proto_depIdxs,
-		EnumOutputTypes:      xxx_File_extensions_proto3_ext3_proto_enumTypes[:],
-		MessageOutputTypes:   messageTypes[:],
-		ExtensionOutputTypes: extensionTypes[:],
+		EnumOutputTypes:      xxx_File_extensions_proto3_ext3_proto_enumTypes,
+		MessageOutputTypes:   messageTypes,
+		ExtensionOutputTypes: extensionTypes,
 	}.Init()
 	messageGoTypes := xxx_File_extensions_proto3_ext3_proto_goTypes[1:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_extensions_proto3_ext3_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_extensions_proto3_ext3_proto_messageTypes[i].PBType = mt
 	}
diff --git a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
index c044d1c..d5ac0dc 100644
--- a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
+++ b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
@@ -385,7 +385,7 @@
 
 var File_fieldnames_fieldnames_proto protoreflect.FileDescriptor
 
-var xxx_File_fieldnames_fieldnames_proto_messageTypes [2]protoimpl.MessageType
+var xxx_File_fieldnames_fieldnames_proto_messageTypes = make([]protoimpl.MessageType, 2)
 var xxx_File_fieldnames_fieldnames_proto_goTypes = []interface{}{
 	(*Message)(nil),                      // 0: goproto.protoc.fieldnames.Message
 	(*Message_OneofMessageConflict)(nil), // 1: goproto.protoc.fieldnames.Message.OneofMessageConflict
@@ -393,15 +393,15 @@
 var xxx_File_fieldnames_fieldnames_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [2]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 2)
 	File_fieldnames_fieldnames_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_fieldnames_fieldnames_proto_rawdesc,
 		GoTypes:            xxx_File_fieldnames_fieldnames_proto_goTypes,
 		DependencyIndexes:  xxx_File_fieldnames_fieldnames_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_fieldnames_fieldnames_proto_goTypes[0:][:2]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_fieldnames_fieldnames_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_fieldnames_fieldnames_proto_messageTypes[i].PBType = mt
 	}
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 afc439f..eabb69c 100644
--- a/cmd/protoc-gen-go/testdata/import_public/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/a.pb.go
@@ -158,7 +158,7 @@
 
 var File_import_public_a_proto protoreflect.FileDescriptor
 
-var xxx_File_import_public_a_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_import_public_a_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_import_public_a_proto_goTypes = []interface{}{
 	(*Public)(nil), // 0: goproto.protoc.import_public.Public
 	(*sub.M)(nil),  // 1: goproto.protoc.import_public.sub.M
@@ -172,15 +172,15 @@
 }
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_import_public_a_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_import_public_a_proto_rawdesc,
 		GoTypes:            xxx_File_import_public_a_proto_goTypes,
 		DependencyIndexes:  xxx_File_import_public_a_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_import_public_a_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_import_public_a_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_import_public_a_proto_messageTypes[i].PBType = mt
 	}
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 9f07728..9d10afc 100644
--- a/cmd/protoc-gen-go/testdata/import_public/b.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/b.pb.go
@@ -100,7 +100,7 @@
 
 var File_import_public_b_proto protoreflect.FileDescriptor
 
-var xxx_File_import_public_b_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_import_public_b_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_import_public_b_proto_goTypes = []interface{}{
 	(*Local)(nil), // 0: goproto.protoc.import_public.Local
 	(*sub.M)(nil), // 1: goproto.protoc.import_public.sub.M
@@ -112,15 +112,15 @@
 }
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_import_public_b_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_import_public_b_proto_rawdesc,
 		GoTypes:            xxx_File_import_public_b_proto_goTypes,
 		DependencyIndexes:  xxx_File_import_public_b_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_import_public_b_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_import_public_b_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_import_public_b_proto_messageTypes[i].PBType = mt
 	}
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 3db3cb5..6c189b0 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
@@ -443,8 +443,8 @@
 
 var File_import_public_sub_a_proto protoreflect.FileDescriptor
 
-var xxx_File_import_public_sub_a_proto_enumTypes [3]protoreflect.EnumType
-var xxx_File_import_public_sub_a_proto_messageTypes [2]protoimpl.MessageType
+var xxx_File_import_public_sub_a_proto_enumTypes = make([]protoreflect.EnumType, 3)
+var xxx_File_import_public_sub_a_proto_messageTypes = make([]protoimpl.MessageType, 2)
 var xxx_File_import_public_sub_a_proto_goTypes = []interface{}{
 	(E)(0),                               // 0: goproto.protoc.import_public.sub.E
 	(M_Subenum)(0),                       // 1: goproto.protoc.import_public.sub.M.Subenum
@@ -459,18 +459,18 @@
 }
 
 func init() {
-	var messageTypes [2]protoreflect.MessageType
-	var extensionTypes [1]protoreflect.ExtensionType
+	messageTypes := make([]protoreflect.MessageType, 2)
+	extensionTypes := make([]protoreflect.ExtensionType, 1)
 	File_import_public_sub_a_proto = protoimpl.FileBuilder{
 		RawDescriptor:        xxx_File_import_public_sub_a_proto_rawdesc,
 		GoTypes:              xxx_File_import_public_sub_a_proto_goTypes,
 		DependencyIndexes:    xxx_File_import_public_sub_a_proto_depIdxs,
-		EnumOutputTypes:      xxx_File_import_public_sub_a_proto_enumTypes[:],
-		MessageOutputTypes:   messageTypes[:],
-		ExtensionOutputTypes: extensionTypes[:],
+		EnumOutputTypes:      xxx_File_import_public_sub_a_proto_enumTypes,
+		MessageOutputTypes:   messageTypes,
+		ExtensionOutputTypes: extensionTypes,
 	}.Init()
 	messageGoTypes := xxx_File_import_public_sub_a_proto_goTypes[3:][:2]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 212681c..0ee712e 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
@@ -76,22 +76,22 @@
 
 var File_import_public_sub_b_proto protoreflect.FileDescriptor
 
-var xxx_File_import_public_sub_b_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_import_public_sub_b_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_import_public_sub_b_proto_goTypes = []interface{}{
 	(*M2)(nil), // 0: goproto.protoc.import_public.sub.M2
 }
 var xxx_File_import_public_sub_b_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_import_public_sub_b_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_import_public_sub_b_proto_rawdesc,
 		GoTypes:            xxx_File_import_public_sub_b_proto_goTypes,
 		DependencyIndexes:  xxx_File_import_public_sub_b_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_import_public_sub_b_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 9e0a934..75f60a3 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
@@ -76,22 +76,22 @@
 
 var File_import_public_sub2_a_proto protoreflect.FileDescriptor
 
-var xxx_File_import_public_sub2_a_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_import_public_sub2_a_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_import_public_sub2_a_proto_goTypes = []interface{}{
 	(*Sub2Message)(nil), // 0: goproto.protoc.import_public.sub2.Sub2Message
 }
 var xxx_File_import_public_sub2_a_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_import_public_sub2_a_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_import_public_sub2_a_proto_rawdesc,
 		GoTypes:            xxx_File_import_public_sub2_a_proto_goTypes,
 		DependencyIndexes:  xxx_File_import_public_sub2_a_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_import_public_sub2_a_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 cef90a4..5a65bc1 100644
--- a/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
@@ -73,22 +73,22 @@
 
 var File_imports_fmt_m_proto protoreflect.FileDescriptor
 
-var xxx_File_imports_fmt_m_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_imports_fmt_m_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_imports_fmt_m_proto_goTypes = []interface{}{
 	(*M)(nil), // 0: fmt.M
 }
 var xxx_File_imports_fmt_m_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_fmt_m_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_fmt_m_proto_rawdesc,
 		GoTypes:            xxx_File_imports_fmt_m_proto_goTypes,
 		DependencyIndexes:  xxx_File_imports_fmt_m_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_imports_fmt_m_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_imports_fmt_m_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_imports_fmt_m_proto_messageTypes[i].PBType = mt
 	}
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 fb56be3..2cef772 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
@@ -150,8 +150,8 @@
 
 var File_imports_test_a_1_m1_proto protoreflect.FileDescriptor
 
-var xxx_File_imports_test_a_1_m1_proto_enumTypes [1]protoreflect.EnumType
-var xxx_File_imports_test_a_1_m1_proto_messageTypes [2]protoimpl.MessageType
+var xxx_File_imports_test_a_1_m1_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var xxx_File_imports_test_a_1_m1_proto_messageTypes = make([]protoimpl.MessageType, 2)
 var xxx_File_imports_test_a_1_m1_proto_goTypes = []interface{}{
 	(E1)(0),      // 0: test.a.E1
 	(*M1)(nil),   // 1: test.a.M1
@@ -162,16 +162,16 @@
 }
 
 func init() {
-	var messageTypes [2]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 2)
 	File_imports_test_a_1_m1_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_a_1_m1_proto_rawdesc,
 		GoTypes:            xxx_File_imports_test_a_1_m1_proto_goTypes,
 		DependencyIndexes:  xxx_File_imports_test_a_1_m1_proto_depIdxs,
-		EnumOutputTypes:    xxx_File_imports_test_a_1_m1_proto_enumTypes[:],
-		MessageOutputTypes: messageTypes[:],
+		EnumOutputTypes:    xxx_File_imports_test_a_1_m1_proto_enumTypes,
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_imports_test_a_1_m1_proto_goTypes[1:][:2]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 b1250a7..c7600af 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
@@ -74,22 +74,22 @@
 
 var File_imports_test_a_1_m2_proto protoreflect.FileDescriptor
 
-var xxx_File_imports_test_a_1_m2_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_imports_test_a_1_m2_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_imports_test_a_1_m2_proto_goTypes = []interface{}{
 	(*M2)(nil), // 0: test.a.M2
 }
 var xxx_File_imports_test_a_1_m2_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_a_1_m2_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_a_1_m2_proto_rawdesc,
 		GoTypes:            xxx_File_imports_test_a_1_m2_proto_goTypes,
 		DependencyIndexes:  xxx_File_imports_test_a_1_m2_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_imports_test_a_1_m2_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 f05c60e..561c462 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
@@ -74,22 +74,22 @@
 
 var File_imports_test_a_2_m3_proto protoreflect.FileDescriptor
 
-var xxx_File_imports_test_a_2_m3_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_imports_test_a_2_m3_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_imports_test_a_2_m3_proto_goTypes = []interface{}{
 	(*M3)(nil), // 0: test.a.M3
 }
 var xxx_File_imports_test_a_2_m3_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_a_2_m3_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_a_2_m3_proto_rawdesc,
 		GoTypes:            xxx_File_imports_test_a_2_m3_proto_goTypes,
 		DependencyIndexes:  xxx_File_imports_test_a_2_m3_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_imports_test_a_2_m3_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 cfca353..2d2776d 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
@@ -74,22 +74,22 @@
 
 var File_imports_test_a_2_m4_proto protoreflect.FileDescriptor
 
-var xxx_File_imports_test_a_2_m4_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_imports_test_a_2_m4_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_imports_test_a_2_m4_proto_goTypes = []interface{}{
 	(*M4)(nil), // 0: test.a.M4
 }
 var xxx_File_imports_test_a_2_m4_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_a_2_m4_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_a_2_m4_proto_rawdesc,
 		GoTypes:            xxx_File_imports_test_a_2_m4_proto_goTypes,
 		DependencyIndexes:  xxx_File_imports_test_a_2_m4_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_imports_test_a_2_m4_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 a116386..3829aaa 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
@@ -75,22 +75,22 @@
 
 var File_imports_test_b_1_m1_proto protoreflect.FileDescriptor
 
-var xxx_File_imports_test_b_1_m1_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_imports_test_b_1_m1_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_imports_test_b_1_m1_proto_goTypes = []interface{}{
 	(*M1)(nil), // 0: test.b.part1.M1
 }
 var xxx_File_imports_test_b_1_m1_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_b_1_m1_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_b_1_m1_proto_rawdesc,
 		GoTypes:            xxx_File_imports_test_b_1_m1_proto_goTypes,
 		DependencyIndexes:  xxx_File_imports_test_b_1_m1_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_imports_test_b_1_m1_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 f7da208..6e66abd 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
@@ -75,22 +75,22 @@
 
 var File_imports_test_b_1_m2_proto protoreflect.FileDescriptor
 
-var xxx_File_imports_test_b_1_m2_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_imports_test_b_1_m2_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_imports_test_b_1_m2_proto_goTypes = []interface{}{
 	(*M2)(nil), // 0: test.b.part2.M2
 }
 var xxx_File_imports_test_b_1_m2_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_b_1_m2_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_b_1_m2_proto_rawdesc,
 		GoTypes:            xxx_File_imports_test_b_1_m2_proto_goTypes,
 		DependencyIndexes:  xxx_File_imports_test_b_1_m2_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_imports_test_b_1_m2_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 b6f66f3..ced9f62 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
@@ -86,7 +86,7 @@
 
 var File_imports_test_import_a1m1_proto protoreflect.FileDescriptor
 
-var xxx_File_imports_test_import_a1m1_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_imports_test_import_a1m1_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_imports_test_import_a1m1_proto_goTypes = []interface{}{
 	(*A1M1)(nil),        // 0: test.A1M1
 	(*test_a_1.M1)(nil), // 1: test.a.M1
@@ -96,15 +96,15 @@
 }
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_import_a1m1_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_import_a1m1_proto_rawdesc,
 		GoTypes:            xxx_File_imports_test_import_a1m1_proto_goTypes,
 		DependencyIndexes:  xxx_File_imports_test_import_a1m1_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_imports_test_import_a1m1_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 3485ea9..6e2f4b4 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
@@ -86,7 +86,7 @@
 
 var File_imports_test_import_a1m2_proto protoreflect.FileDescriptor
 
-var xxx_File_imports_test_import_a1m2_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_imports_test_import_a1m2_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_imports_test_import_a1m2_proto_goTypes = []interface{}{
 	(*A1M2)(nil),        // 0: test.A1M2
 	(*test_a_1.M2)(nil), // 1: test.a.M2
@@ -96,15 +96,15 @@
 }
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_import_a1m2_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_import_a1m2_proto_rawdesc,
 		GoTypes:            xxx_File_imports_test_import_a1m2_proto_goTypes,
 		DependencyIndexes:  xxx_File_imports_test_import_a1m2_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_imports_test_import_a1m2_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 7c715b2..4f4c028 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
@@ -139,7 +139,7 @@
 
 var File_imports_test_import_all_proto protoreflect.FileDescriptor
 
-var xxx_File_imports_test_import_all_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_imports_test_import_all_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_imports_test_import_all_proto_goTypes = []interface{}{
 	(*All)(nil),         // 0: test.All
 	(*test_a_1.M1)(nil), // 1: test.a.M1
@@ -157,15 +157,15 @@
 }
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_import_all_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_import_all_proto_rawdesc,
 		GoTypes:            xxx_File_imports_test_import_all_proto_goTypes,
 		DependencyIndexes:  xxx_File_imports_test_import_all_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_imports_test_import_all_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
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 55da1e6..300ddbc 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
@@ -106,22 +106,22 @@
 
 var File_issue780_oneof_conflict_test_proto protoreflect.FileDescriptor
 
-var xxx_File_issue780_oneof_conflict_test_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_issue780_oneof_conflict_test_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_issue780_oneof_conflict_test_proto_goTypes = []interface{}{
 	(*Foo)(nil), // 0: oneoftest.Foo
 }
 var xxx_File_issue780_oneof_conflict_test_proto_depIdxs = []int32{}
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_issue780_oneof_conflict_test_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_issue780_oneof_conflict_test_proto_rawdesc,
 		GoTypes:            xxx_File_issue780_oneof_conflict_test_proto_goTypes,
 		DependencyIndexes:  xxx_File_issue780_oneof_conflict_test_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_issue780_oneof_conflict_test_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		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
 	}
diff --git a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
index ea369ea..4d252a9 100644
--- a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
+++ b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
@@ -138,8 +138,8 @@
 
 var File_nopackage_nopackage_proto protoreflect.FileDescriptor
 
-var xxx_File_nopackage_nopackage_proto_enumTypes [1]protoreflect.EnumType
-var xxx_File_nopackage_nopackage_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_nopackage_nopackage_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var xxx_File_nopackage_nopackage_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_nopackage_nopackage_proto_goTypes = []interface{}{
 	(Enum)(0),       // 0: Enum
 	(*Message)(nil), // 1: Message
@@ -149,16 +149,16 @@
 }
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_nopackage_nopackage_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_nopackage_nopackage_proto_rawdesc,
 		GoTypes:            xxx_File_nopackage_nopackage_proto_goTypes,
 		DependencyIndexes:  xxx_File_nopackage_nopackage_proto_depIdxs,
-		EnumOutputTypes:    xxx_File_nopackage_nopackage_proto_enumTypes[:],
-		MessageOutputTypes: messageTypes[:],
+		EnumOutputTypes:    xxx_File_nopackage_nopackage_proto_enumTypes,
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_nopackage_nopackage_proto_goTypes[1:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_nopackage_nopackage_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_nopackage_nopackage_proto_messageTypes[i].PBType = mt
 	}
diff --git a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
index 96dd21b..866e157 100644
--- a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
@@ -446,8 +446,8 @@
 
 var File_proto2_enum_proto protoreflect.FileDescriptor
 
-var xxx_File_proto2_enum_proto_enumTypes [6]protoreflect.EnumType
-var xxx_File_proto2_enum_proto_messageTypes [2]protoimpl.MessageType
+var xxx_File_proto2_enum_proto_enumTypes = make([]protoreflect.EnumType, 6)
+var xxx_File_proto2_enum_proto_messageTypes = make([]protoimpl.MessageType, 2)
 var xxx_File_proto2_enum_proto_goTypes = []interface{}{
 	(EnumType1)(0), // 0: goproto.protoc.proto2.EnumType1
 	(EnumType2)(0), // 1: goproto.protoc.proto2.EnumType2
@@ -464,16 +464,16 @@
 }
 
 func init() {
-	var messageTypes [2]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 2)
 	File_proto2_enum_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_proto2_enum_proto_rawdesc,
 		GoTypes:            xxx_File_proto2_enum_proto_goTypes,
 		DependencyIndexes:  xxx_File_proto2_enum_proto_depIdxs,
-		EnumOutputTypes:    xxx_File_proto2_enum_proto_enumTypes[:],
-		MessageOutputTypes: messageTypes[:],
+		EnumOutputTypes:    xxx_File_proto2_enum_proto_enumTypes,
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_proto2_enum_proto_goTypes[6:][:2]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_proto2_enum_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_proto2_enum_proto_messageTypes[i].PBType = mt
 	}
diff --git a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
index 9e25078..101ceeb 100644
--- a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
@@ -1718,8 +1718,8 @@
 
 var File_proto2_fields_proto protoreflect.FileDescriptor
 
-var xxx_File_proto2_fields_proto_enumTypes [1]protoreflect.EnumType
-var xxx_File_proto2_fields_proto_messageTypes [9]protoimpl.MessageType
+var xxx_File_proto2_fields_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var xxx_File_proto2_fields_proto_messageTypes = make([]protoimpl.MessageType, 9)
 var xxx_File_proto2_fields_proto_goTypes = []interface{}{
 	(FieldTestMessage_Enum)(0),             // 0: goproto.protoc.proto2.FieldTestMessage.Enum
 	(*FieldTestMessage)(nil),               // 1: goproto.protoc.proto2.FieldTestMessage
@@ -1754,16 +1754,16 @@
 }
 
 func init() {
-	var messageTypes [9]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 9)
 	File_proto2_fields_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_proto2_fields_proto_rawdesc,
 		GoTypes:            xxx_File_proto2_fields_proto_goTypes,
 		DependencyIndexes:  xxx_File_proto2_fields_proto_depIdxs,
-		EnumOutputTypes:    xxx_File_proto2_fields_proto_enumTypes[:],
-		MessageOutputTypes: messageTypes[:],
+		EnumOutputTypes:    xxx_File_proto2_fields_proto_enumTypes,
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_proto2_fields_proto_goTypes[1:][:9]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_proto2_fields_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_proto2_fields_proto_messageTypes[i].PBType = mt
 	}
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 80147a5..52cb39f 100644
--- a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
@@ -181,7 +181,7 @@
 
 var File_proto2_nested_messages_proto protoreflect.FileDescriptor
 
-var xxx_File_proto2_nested_messages_proto_messageTypes [3]protoimpl.MessageType
+var xxx_File_proto2_nested_messages_proto_messageTypes = make([]protoimpl.MessageType, 3)
 var xxx_File_proto2_nested_messages_proto_goTypes = []interface{}{
 	(*Layer1)(nil),               // 0: goproto.protoc.proto2.Layer1
 	(*Layer1_Layer2)(nil),        // 1: goproto.protoc.proto2.Layer1.Layer2
@@ -194,15 +194,15 @@
 }
 
 func init() {
-	var messageTypes [3]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 3)
 	File_proto2_nested_messages_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_proto2_nested_messages_proto_rawdesc,
 		GoTypes:            xxx_File_proto2_nested_messages_proto_goTypes,
 		DependencyIndexes:  xxx_File_proto2_nested_messages_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_proto2_nested_messages_proto_goTypes[0:][:3]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_proto2_nested_messages_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_proto2_nested_messages_proto_messageTypes[i].PBType = mt
 	}
diff --git a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
index 2a7a8df..6f1970d 100644
--- a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
@@ -94,7 +94,7 @@
 
 var File_proto2_proto2_proto protoreflect.FileDescriptor
 
-var xxx_File_proto2_proto2_proto_messageTypes [1]protoimpl.MessageType
+var xxx_File_proto2_proto2_proto_messageTypes = make([]protoimpl.MessageType, 1)
 var xxx_File_proto2_proto2_proto_goTypes = []interface{}{
 	(*Message)(nil), // 0: goproto.protoc.proto2.Message
 }
@@ -103,15 +103,15 @@
 }
 
 func init() {
-	var messageTypes [1]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 1)
 	File_proto2_proto2_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_proto2_proto2_proto_rawdesc,
 		GoTypes:            xxx_File_proto2_proto2_proto_goTypes,
 		DependencyIndexes:  xxx_File_proto2_proto2_proto_depIdxs,
-		MessageOutputTypes: messageTypes[:],
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_proto2_proto2_proto_goTypes[0:][:1]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_proto2_proto2_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_proto2_proto2_proto_messageTypes[i].PBType = mt
 	}
diff --git a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
index be3a781..81a82c2 100644
--- a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
@@ -76,7 +76,7 @@
 
 var File_proto3_enum_proto protoreflect.FileDescriptor
 
-var xxx_File_proto3_enum_proto_enumTypes [1]protoreflect.EnumType
+var xxx_File_proto3_enum_proto_enumTypes = make([]protoreflect.EnumType, 1)
 var xxx_File_proto3_enum_proto_goTypes = []interface{}{
 	(Enum)(0), // 0: goproto.protoc.proto3.Enum
 }
@@ -87,7 +87,7 @@
 		RawDescriptor:     xxx_File_proto3_enum_proto_rawdesc,
 		GoTypes:           xxx_File_proto3_enum_proto_goTypes,
 		DependencyIndexes: xxx_File_proto3_enum_proto_depIdxs,
-		EnumOutputTypes:   xxx_File_proto3_enum_proto_enumTypes[:],
+		EnumOutputTypes:   xxx_File_proto3_enum_proto_enumTypes,
 	}.Init()
 	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 2cf26ce..d6b2b6b 100644
--- a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
@@ -579,8 +579,8 @@
 
 var File_proto3_fields_proto protoreflect.FileDescriptor
 
-var xxx_File_proto3_fields_proto_enumTypes [1]protoreflect.EnumType
-var xxx_File_proto3_fields_proto_messageTypes [5]protoimpl.MessageType
+var xxx_File_proto3_fields_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var xxx_File_proto3_fields_proto_messageTypes = make([]protoimpl.MessageType, 5)
 var xxx_File_proto3_fields_proto_goTypes = []interface{}{
 	(FieldTestMessage_Enum)(0),       // 0: goproto.protoc.proto3.FieldTestMessage.Enum
 	(*FieldTestMessage)(nil),         // 1: goproto.protoc.proto3.FieldTestMessage
@@ -602,16 +602,16 @@
 }
 
 func init() {
-	var messageTypes [5]protoreflect.MessageType
+	messageTypes := make([]protoreflect.MessageType, 5)
 	File_proto3_fields_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_proto3_fields_proto_rawdesc,
 		GoTypes:            xxx_File_proto3_fields_proto_goTypes,
 		DependencyIndexes:  xxx_File_proto3_fields_proto_depIdxs,
-		EnumOutputTypes:    xxx_File_proto3_fields_proto_enumTypes[:],
-		MessageOutputTypes: messageTypes[:],
+		EnumOutputTypes:    xxx_File_proto3_fields_proto_enumTypes,
+		MessageOutputTypes: messageTypes,
 	}.Init()
 	messageGoTypes := xxx_File_proto3_fields_proto_goTypes[1:][:5]
-	for i, mt := range messageTypes[:] {
+	for i, mt := range messageTypes {
 		xxx_File_proto3_fields_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
 		xxx_File_proto3_fields_proto_messageTypes[i].PBType = mt
 	}