Преглед изворни кода

cmd/protoc-gen-go: enforce init order within packages

Ensure that the init funcs for files within a Go package run in the
dependency order of the source .proto files. That is, if a.proto and b.proto
are part of the same Go package, and a.proto imports b.proto, then b.pb.go's
init funcs must run before a.pb.go's.

Change-Id: I0e86ff22e5c4cab9df7a73fe4805390fadd34b0d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/166419
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Herbie Ong <herbie@google.com>
Damien Neil пре 6 година
родитељ
комит
0fc224513b
57 измењених фајлова са 395 додато и 55 уклоњено
  1. 6 1
      cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
  2. 5 1
      cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
  3. 21 1
      cmd/protoc-gen-go/internal_gengo/reflect.go
  4. 5 1
      cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
  5. 5 1
      cmd/protoc-gen-go/testdata/comments/comments.pb.go
  6. 5 1
      cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
  7. 5 1
      cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
  8. 5 1
      cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
  9. 5 1
      cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
  10. 5 1
      cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
  11. 5 1
      cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
  12. 6 1
      cmd/protoc-gen-go/testdata/import_public/a.pb.go
  13. 5 1
      cmd/protoc-gen-go/testdata/import_public/b.pb.go
  14. 6 1
      cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
  15. 5 1
      cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
  16. 5 1
      cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
  17. 5 1
      cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
  18. 5 1
      cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
  19. 5 1
      cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
  20. 5 1
      cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
  21. 5 1
      cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
  22. 5 1
      cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
  23. 5 1
      cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
  24. 5 1
      cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
  25. 5 1
      cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
  26. 5 1
      cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
  27. 5 1
      cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
  28. 5 1
      cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
  29. 5 1
      cmd/protoc-gen-go/testdata/proto2/enum.pb.go
  30. 5 1
      cmd/protoc-gen-go/testdata/proto2/fields.pb.go
  31. 5 1
      cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
  32. 5 1
      cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
  33. 5 1
      cmd/protoc-gen-go/testdata/proto3/enum.pb.go
  34. 5 1
      cmd/protoc-gen-go/testdata/proto3/fields.pb.go
  35. 5 1
      encoding/testprotos/pb2/test.pb.go
  36. 5 1
      encoding/testprotos/pb3/test.pb.go
  37. 5 1
      internal/testprotos/conformance/conformance.pb.go
  38. 5 1
      internal/testprotos/legacy/legacy.pb.go
  39. 79 0
      internal/testprotos/test/ext.pb.go
  40. 15 0
      internal/testprotos/test/ext.proto
  41. 8 1
      internal/testprotos/test/test.pb.go
  42. 5 1
      internal/testprotos/test/test_import.pb.go
  43. 5 1
      internal/testprotos/test/test_public.pb.go
  44. 5 1
      internal/testprotos/test/test_weak.pb.go
  45. 5 1
      reflect/protoregistry/testprotos/test.pb.go
  46. 5 1
      types/descriptor/descriptor.pb.go
  47. 5 1
      types/known/any.pb.go
  48. 7 1
      types/known/api.pb.go
  49. 5 1
      types/known/duration.pb.go
  50. 5 1
      types/known/empty.pb.go
  51. 5 1
      types/known/field_mask.pb.go
  52. 5 1
      types/known/source_context.pb.go
  53. 5 1
      types/known/struct.pb.go
  54. 5 1
      types/known/timestamp.pb.go
  55. 7 1
      types/known/type.pb.go
  56. 5 1
      types/known/wrappers.pb.go
  57. 5 1
      types/plugin/plugin.pb.go

+ 6 - 1
cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go

@@ -55,7 +55,12 @@ var xxx_File_grpc_deprecation_proto_depIdxs = []int32{
 	1, // goproto.protoc.grpc.DeprecatedService.DeprecatedCall:output_type -> goproto.protoc.grpc.Response
 }
 
-func init() {
+func init() { xxx_File_grpc_deprecation_proto_init() }
+func xxx_File_grpc_deprecation_proto_init() {
+	if File_grpc_deprecation_proto != nil {
+		return
+	}
+	xxx_File_grpc_grpc_proto_init()
 	File_grpc_deprecation_proto = protoimpl.FileBuilder{
 		RawDescriptor:     xxx_File_grpc_deprecation_proto_rawdesc,
 		GoTypes:           xxx_File_grpc_deprecation_proto_goTypes,

+ 5 - 1
cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go

@@ -147,7 +147,11 @@ var xxx_File_grpc_grpc_proto_depIdxs = []int32{
 	1, // goproto.protoc.grpc.test_service.bidi_call:output_type -> goproto.protoc.grpc.Response
 }
 
-func init() {
+func init() { xxx_File_grpc_grpc_proto_init() }
+func xxx_File_grpc_grpc_proto_init() {
+	if File_grpc_grpc_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 2)
 	File_grpc_grpc_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_grpc_grpc_proto_rawdesc,

+ 21 - 1
cmd/protoc-gen-go/internal_gengo/reflect.go

@@ -151,7 +151,24 @@ func genReflectFileDescriptor(gen *protogen.Plugin, g *protogen.GeneratedFile, f
 	}
 	g.P("}")
 
-	g.P("func init() {")
+	g.P("func init() { ", initFuncName(f.File), "() }")
+
+	g.P("func ", initFuncName(f.File), "() {")
+	g.P("if ", f.GoDescriptorIdent, " != nil {")
+	g.P("return")
+	g.P("}")
+
+	// Ensure that initialization functions for different files in the same Go
+	// package run in the correct order: Call the init funcs for every .proto file
+	// imported by this one that is in the same Go package.
+	for i, imps := 0, f.Desc.Imports(); i < imps.Len(); i++ {
+		impFile, _ := gen.FileByName(imps.Get(i).Path())
+		if impFile.GoImportPath != f.GoImportPath {
+			continue
+		}
+		g.P(initFuncName(impFile), "()")
+	}
+
 	if len(f.allMessages) > 0 {
 		g.P("messageTypes := make([]", protoreflectPackage.Ident("MessageType"), ",", len(f.allMessages), ")")
 	}
@@ -245,3 +262,6 @@ func enumTypesVarName(f *fileInfo) string {
 func messageTypesVarName(f *fileInfo) string {
 	return "xxx_" + f.GoDescriptorIdent.GoName + "_messageTypes"
 }
+func initFuncName(f *protogen.File) string {
+	return "xxx_" + f.GoDescriptorIdent.GoName + "_init"
+}

+ 5 - 1
cmd/protoc-gen-go/testdata/annotations/annotations.pb.go

@@ -144,7 +144,11 @@ var xxx_File_annotations_annotations_proto_goTypes = []interface{}{
 }
 var xxx_File_annotations_annotations_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_annotations_annotations_proto_init() }
+func xxx_File_annotations_annotations_proto_init() {
+	if File_annotations_annotations_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_annotations_annotations_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_annotations_annotations_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/comments/comments.pb.go

@@ -323,7 +323,11 @@ var xxx_File_comments_comments_proto_goTypes = []interface{}{
 }
 var xxx_File_comments_comments_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_comments_comments_proto_init() }
+func xxx_File_comments_comments_proto_init() {
+	if File_comments_comments_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 6)
 	File_comments_comments_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_comments_comments_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/comments/deprecated.pb.go

@@ -129,7 +129,11 @@ var xxx_File_comments_deprecated_proto_goTypes = []interface{}{
 }
 var xxx_File_comments_deprecated_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_comments_deprecated_proto_init() }
+func xxx_File_comments_deprecated_proto_init() {
+	if File_comments_deprecated_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_comments_deprecated_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_comments_deprecated_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/extensions/base/base.pb.go

@@ -150,7 +150,11 @@ var xxx_File_extensions_base_base_proto_goTypes = []interface{}{
 }
 var xxx_File_extensions_base_base_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_extensions_base_base_proto_init() }
+func xxx_File_extensions_base_base_proto_init() {
+	if File_extensions_base_base_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 2)
 	File_extensions_base_base_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_extensions_base_base_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go

@@ -1226,7 +1226,11 @@ var xxx_File_extensions_ext_ext_proto_depIdxs = []int32{
 	6,  // goproto.protoc.extension.ext.MessageSetWireFormatExtension.message_set_extension:type_name -> goproto.protoc.extension.ext.MessageSetWireFormatExtension
 }
 
-func init() {
+func init() { xxx_File_extensions_ext_ext_proto_init() }
+func xxx_File_extensions_ext_ext_proto_init() {
+	if File_extensions_ext_ext_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 8)
 	extensionTypes := make([]protoreflect.ExtensionType, 44)
 	File_extensions_ext_ext_proto = protoimpl.FileBuilder{

+ 5 - 1
cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go

@@ -91,7 +91,11 @@ var xxx_File_extensions_extra_extra_proto_goTypes = []interface{}{
 }
 var xxx_File_extensions_extra_extra_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_extensions_extra_extra_proto_init() }
+func xxx_File_extensions_extra_extra_proto_init() {
+	if File_extensions_extra_extra_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_extensions_extra_extra_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_extensions_extra_extra_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go

@@ -690,7 +690,11 @@ var xxx_File_extensions_proto3_ext3_proto_depIdxs = []int32{
 	1, // goproto.protoc.extension.proto3.repeated_extension_Message:type_name -> goproto.protoc.extension.proto3.Message
 }
 
-func init() {
+func init() { xxx_File_extensions_proto3_ext3_proto_init() }
+func xxx_File_extensions_proto3_ext3_proto_init() {
+	if File_extensions_proto3_ext3_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	extensionTypes := make([]protoreflect.ExtensionType, 34)
 	File_extensions_proto3_ext3_proto = protoimpl.FileBuilder{

+ 5 - 1
cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go

@@ -392,7 +392,11 @@ var xxx_File_fieldnames_fieldnames_proto_goTypes = []interface{}{
 }
 var xxx_File_fieldnames_fieldnames_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_fieldnames_fieldnames_proto_init() }
+func xxx_File_fieldnames_fieldnames_proto_init() {
+	if File_fieldnames_fieldnames_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 2)
 	File_fieldnames_fieldnames_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_fieldnames_fieldnames_proto_rawdesc,

+ 6 - 1
cmd/protoc-gen-go/testdata/import_public/a.pb.go

@@ -171,7 +171,12 @@ var xxx_File_import_public_a_proto_depIdxs = []int32{
 	3, // goproto.protoc.import_public.Public.local:type_name -> goproto.protoc.import_public.Local
 }
 
-func init() {
+func init() { xxx_File_import_public_a_proto_init() }
+func xxx_File_import_public_a_proto_init() {
+	if File_import_public_a_proto != nil {
+		return
+	}
+	xxx_File_import_public_b_proto_init()
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_import_public_a_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_import_public_a_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/import_public/b.pb.go

@@ -111,7 +111,11 @@ var xxx_File_import_public_b_proto_depIdxs = []int32{
 	2, // goproto.protoc.import_public.Local.e:type_name -> goproto.protoc.import_public.sub.E
 }
 
-func init() {
+func init() { xxx_File_import_public_b_proto_init() }
+func xxx_File_import_public_b_proto_init() {
+	if File_import_public_b_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_import_public_b_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_import_public_b_proto_rawdesc,

+ 6 - 1
cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go

@@ -458,7 +458,12 @@ var xxx_File_import_public_sub_a_proto_depIdxs = []int32{
 	5, // goproto.protoc.import_public.sub.M.m2:type_name -> goproto.protoc.import_public.sub.M2
 }
 
-func init() {
+func init() { xxx_File_import_public_sub_a_proto_init() }
+func xxx_File_import_public_sub_a_proto_init() {
+	if File_import_public_sub_a_proto != nil {
+		return
+	}
+	xxx_File_import_public_sub_b_proto_init()
 	messageTypes := make([]protoreflect.MessageType, 2)
 	extensionTypes := make([]protoreflect.ExtensionType, 1)
 	File_import_public_sub_a_proto = protoimpl.FileBuilder{

+ 5 - 1
cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go

@@ -82,7 +82,11 @@ var xxx_File_import_public_sub_b_proto_goTypes = []interface{}{
 }
 var xxx_File_import_public_sub_b_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_import_public_sub_b_proto_init() }
+func xxx_File_import_public_sub_b_proto_init() {
+	if File_import_public_sub_b_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_import_public_sub_b_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_import_public_sub_b_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go

@@ -82,7 +82,11 @@ var xxx_File_import_public_sub2_a_proto_goTypes = []interface{}{
 }
 var xxx_File_import_public_sub2_a_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_import_public_sub2_a_proto_init() }
+func xxx_File_import_public_sub2_a_proto_init() {
+	if File_import_public_sub2_a_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_import_public_sub2_a_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_import_public_sub2_a_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go

@@ -79,7 +79,11 @@ var xxx_File_imports_fmt_m_proto_goTypes = []interface{}{
 }
 var xxx_File_imports_fmt_m_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_imports_fmt_m_proto_init() }
+func xxx_File_imports_fmt_m_proto_init() {
+	if File_imports_fmt_m_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_fmt_m_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_fmt_m_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go

@@ -161,7 +161,11 @@ var xxx_File_imports_test_a_1_m1_proto_depIdxs = []int32{
 	1, // test.a.M1_1.m1:type_name -> test.a.M1
 }
 
-func init() {
+func init() { xxx_File_imports_test_a_1_m1_proto_init() }
+func xxx_File_imports_test_a_1_m1_proto_init() {
+	if File_imports_test_a_1_m1_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 2)
 	File_imports_test_a_1_m1_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_a_1_m1_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go

@@ -80,7 +80,11 @@ var xxx_File_imports_test_a_1_m2_proto_goTypes = []interface{}{
 }
 var xxx_File_imports_test_a_1_m2_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_imports_test_a_1_m2_proto_init() }
+func xxx_File_imports_test_a_1_m2_proto_init() {
+	if File_imports_test_a_1_m2_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_a_1_m2_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_a_1_m2_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go

@@ -80,7 +80,11 @@ var xxx_File_imports_test_a_2_m3_proto_goTypes = []interface{}{
 }
 var xxx_File_imports_test_a_2_m3_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_imports_test_a_2_m3_proto_init() }
+func xxx_File_imports_test_a_2_m3_proto_init() {
+	if File_imports_test_a_2_m3_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_a_2_m3_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_a_2_m3_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go

@@ -80,7 +80,11 @@ var xxx_File_imports_test_a_2_m4_proto_goTypes = []interface{}{
 }
 var xxx_File_imports_test_a_2_m4_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_imports_test_a_2_m4_proto_init() }
+func xxx_File_imports_test_a_2_m4_proto_init() {
+	if File_imports_test_a_2_m4_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_a_2_m4_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_a_2_m4_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go

@@ -81,7 +81,11 @@ var xxx_File_imports_test_b_1_m1_proto_goTypes = []interface{}{
 }
 var xxx_File_imports_test_b_1_m1_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_imports_test_b_1_m1_proto_init() }
+func xxx_File_imports_test_b_1_m1_proto_init() {
+	if File_imports_test_b_1_m1_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_b_1_m1_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_b_1_m1_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go

@@ -81,7 +81,11 @@ var xxx_File_imports_test_b_1_m2_proto_goTypes = []interface{}{
 }
 var xxx_File_imports_test_b_1_m2_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_imports_test_b_1_m2_proto_init() }
+func xxx_File_imports_test_b_1_m2_proto_init() {
+	if File_imports_test_b_1_m2_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_b_1_m2_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_b_1_m2_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go

@@ -95,7 +95,11 @@ var xxx_File_imports_test_import_a1m1_proto_depIdxs = []int32{
 	1, // test.A1M1.f:type_name -> test.a.M1
 }
 
-func init() {
+func init() { xxx_File_imports_test_import_a1m1_proto_init() }
+func xxx_File_imports_test_import_a1m1_proto_init() {
+	if File_imports_test_import_a1m1_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_import_a1m1_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_import_a1m1_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go

@@ -95,7 +95,11 @@ var xxx_File_imports_test_import_a1m2_proto_depIdxs = []int32{
 	1, // test.A1M2.f:type_name -> test.a.M2
 }
 
-func init() {
+func init() { xxx_File_imports_test_import_a1m2_proto_init() }
+func xxx_File_imports_test_import_a1m2_proto_init() {
+	if File_imports_test_import_a1m2_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_import_a1m2_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_import_a1m2_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go

@@ -156,7 +156,11 @@ var xxx_File_imports_test_import_all_proto_depIdxs = []int32{
 	5, // test.All.fmt:type_name -> fmt.M
 }
 
-func init() {
+func init() { xxx_File_imports_test_import_all_proto_init() }
+func xxx_File_imports_test_import_all_proto_init() {
+	if File_imports_test_import_all_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_imports_test_import_all_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_imports_test_import_all_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go

@@ -112,7 +112,11 @@ var xxx_File_issue780_oneof_conflict_test_proto_goTypes = []interface{}{
 }
 var xxx_File_issue780_oneof_conflict_test_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_issue780_oneof_conflict_test_proto_init() }
+func xxx_File_issue780_oneof_conflict_test_proto_init() {
+	if File_issue780_oneof_conflict_test_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_issue780_oneof_conflict_test_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_issue780_oneof_conflict_test_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go

@@ -148,7 +148,11 @@ var xxx_File_nopackage_nopackage_proto_depIdxs = []int32{
 	0, // Message.enum_field:type_name -> Enum
 }
 
-func init() {
+func init() { xxx_File_nopackage_nopackage_proto_init() }
+func xxx_File_nopackage_nopackage_proto_init() {
+	if File_nopackage_nopackage_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_nopackage_nopackage_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_nopackage_nopackage_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/proto2/enum.pb.go

@@ -463,7 +463,11 @@ var xxx_File_proto2_enum_proto_depIdxs = []int32{
 	1, // goproto.protoc.proto2.EnumContainerMessage1.default_duplicate2:type_name -> goproto.protoc.proto2.EnumType2
 }
 
-func init() {
+func init() { xxx_File_proto2_enum_proto_init() }
+func xxx_File_proto2_enum_proto_init() {
+	if File_proto2_enum_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 2)
 	File_proto2_enum_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_proto2_enum_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/proto2/fields.pb.go

@@ -1753,7 +1753,11 @@ var xxx_File_proto2_fields_proto_depIdxs = []int32{
 	0, // goproto.protoc.proto2.FieldTestMessage.MapFixed64EnumEntry.value:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
 }
 
-func init() {
+func init() { xxx_File_proto2_fields_proto_init() }
+func xxx_File_proto2_fields_proto_init() {
+	if File_proto2_fields_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 9)
 	File_proto2_fields_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_proto2_fields_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go

@@ -193,7 +193,11 @@ var xxx_File_proto2_nested_messages_proto_depIdxs = []int32{
 	2, // goproto.protoc.proto2.Layer1.Layer2.l3:type_name -> goproto.protoc.proto2.Layer1.Layer2.Layer3
 }
 
-func init() {
+func init() { xxx_File_proto2_nested_messages_proto_init() }
+func xxx_File_proto2_nested_messages_proto_init() {
+	if File_proto2_nested_messages_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 3)
 	File_proto2_nested_messages_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_proto2_nested_messages_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/proto2/proto2.pb.go

@@ -102,7 +102,11 @@ var xxx_File_proto2_proto2_proto_depIdxs = []int32{
 	0, // goproto.protoc.proto2.Message.m:type_name -> goproto.protoc.proto2.Message
 }
 
-func init() {
+func init() { xxx_File_proto2_proto2_proto_init() }
+func xxx_File_proto2_proto2_proto_init() {
+	if File_proto2_proto2_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_proto2_proto2_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_proto2_proto2_proto_rawdesc,

+ 5 - 1
cmd/protoc-gen-go/testdata/proto3/enum.pb.go

@@ -82,7 +82,11 @@ var xxx_File_proto3_enum_proto_goTypes = []interface{}{
 }
 var xxx_File_proto3_enum_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_proto3_enum_proto_init() }
+func xxx_File_proto3_enum_proto_init() {
+	if File_proto3_enum_proto != nil {
+		return
+	}
 	File_proto3_enum_proto = protoimpl.FileBuilder{
 		RawDescriptor:     xxx_File_proto3_enum_proto_rawdesc,
 		GoTypes:           xxx_File_proto3_enum_proto_goTypes,

+ 5 - 1
cmd/protoc-gen-go/testdata/proto3/fields.pb.go

@@ -601,7 +601,11 @@ var xxx_File_proto3_fields_proto_depIdxs = []int32{
 	0, // goproto.protoc.proto3.FieldTestMessage.MapFixed64EnumEntry.value:type_name -> goproto.protoc.proto3.FieldTestMessage.Enum
 }
 
-func init() {
+func init() { xxx_File_proto3_fields_proto_init() }
+func xxx_File_proto3_fields_proto_init() {
+	if File_proto3_fields_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 5)
 	File_proto3_fields_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_proto3_fields_proto_rawdesc,

+ 5 - 1
encoding/testprotos/pb2/test.pb.go

@@ -2067,7 +2067,11 @@ var xxx_File_pb2_test_proto_depIdxs = []int32{
 	16, // pb2.FakeMessageSetExtension.message_set_extension:type_name -> pb2.FakeMessageSetExtension
 }
 
-func init() {
+func init() { xxx_File_pb2_test_proto_init() }
+func xxx_File_pb2_test_proto_init() {
+	if File_pb2_test_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 20)
 	extensionTypes := make([]protoreflect.ExtensionType, 19)
 	File_pb2_test_proto = protoimpl.FileBuilder{

+ 5 - 1
encoding/testprotos/pb3/test.pb.go

@@ -780,7 +780,11 @@ var xxx_File_pb3_test_proto_depIdxs = []int32{
 	6,  // pb3.Maps.StrToOneofsEntry.value:type_name -> pb3.Oneofs
 }
 
-func init() {
+func init() { xxx_File_pb3_test_proto_init() }
+func xxx_File_pb3_test_proto_init() {
+	if File_pb3_test_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 12)
 	File_pb3_test_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_pb3_test_proto_rawdesc,

+ 5 - 1
internal/testprotos/conformance/conformance.pb.go

@@ -402,7 +402,11 @@ var xxx_File_conformance_conformance_proto_depIdxs = []int32{
 	0, // conformance.ConformanceRequest.requested_output_format:type_name -> conformance.WireFormat
 }
 
-func init() {
+func init() { xxx_File_conformance_conformance_proto_init() }
+func xxx_File_conformance_conformance_proto_init() {
+	if File_conformance_conformance_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 2)
 	File_conformance_conformance_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_conformance_conformance_proto_rawdesc,

+ 5 - 1
internal/testprotos/legacy/legacy.pb.go

@@ -297,7 +297,11 @@ var xxx_File_legacy_legacy_proto_depIdxs = []int32{
 	12, // google.golang.org.Legacy.f12:type_name -> google.golang.org.proto3_20181126.Message
 }
 
-func init() {
+func init() { xxx_File_legacy_legacy_proto_init() }
+func xxx_File_legacy_legacy_proto_init() {
+	if File_legacy_legacy_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_legacy_legacy_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_legacy_legacy_proto_rawdesc,

+ 79 - 0
internal/testprotos/test/ext.pb.go

@@ -0,0 +1,79 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: test/ext.proto
+
+package test
+
+import (
+	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
+	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
+)
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+var E_ForeignInt32Extension = &proto.ExtensionDesc{
+	ExtendedType:  (*TestAllExtensions)(nil),
+	ExtensionType: (*int32)(nil),
+	Field:         2000,
+	Name:          "goproto.proto.test.foreign_int32_extension",
+	Tag:           "varint,2000,opt,name=foreign_int32_extension",
+	Filename:      "test/ext.proto",
+}
+
+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,
+	0x12, 0x12, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
+	0x74, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2e,
+	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3a, 0x5e, 0x0a, 0x17, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e,
+	0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e,
+	0x12, 0x25, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+	0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x78, 0x74,
+	0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd0, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x15,
+	0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x45, 0x78, 0x74, 0x65,
+	0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
+	0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+	0x62, 0x75, 0x66, 0x2f, 0x76, 0x32, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f,
+	0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74,
+}
+
+var xxx_File_test_ext_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_test_ext_proto_rawdesc)
+
+const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+
+var File_test_ext_proto protoreflect.FileDescriptor
+
+var xxx_File_test_ext_proto_goTypes = []interface{}{
+	(*TestAllExtensions)(nil), // 0: goproto.proto.test.TestAllExtensions
+}
+var xxx_File_test_ext_proto_depIdxs = []int32{
+	0, // goproto.proto.test.foreign_int32_extension:extendee -> goproto.proto.test.TestAllExtensions
+}
+
+func init() { xxx_File_test_ext_proto_init() }
+func xxx_File_test_ext_proto_init() {
+	if File_test_ext_proto != nil {
+		return
+	}
+	xxx_File_test_test_proto_init()
+	extensionTypes := make([]protoreflect.ExtensionType, 1)
+	File_test_ext_proto = protoimpl.FileBuilder{
+		RawDescriptor:        xxx_File_test_ext_proto_rawdesc,
+		GoTypes:              xxx_File_test_ext_proto_goTypes,
+		DependencyIndexes:    xxx_File_test_ext_proto_depIdxs,
+		ExtensionOutputTypes: extensionTypes,
+	}.Init()
+	E_ForeignInt32Extension.Type = extensionTypes[0]
+	xxx_File_test_ext_proto_goTypes = nil
+	xxx_File_test_ext_proto_depIdxs = nil
+}

+ 15 - 0
internal/testprotos/test/ext.proto

@@ -0,0 +1,15 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+syntax = "proto2";
+
+package goproto.proto.test;
+
+import "test/test.proto";
+
+option go_package = "github.com/golang/protobuf/v2/internal/testprotos/test";
+
+extend TestAllExtensions {
+  optional int32    foreign_int32_extension =  2000;
+}

+ 8 - 1
internal/testprotos/test/test.pb.go

@@ -2870,7 +2870,14 @@ var xxx_File_test_test_proto_depIdxs = []int32{
 	5,  // goproto.proto.test.TestDeprecatedService.Deprecated:output_type -> goproto.proto.test.TestDeprecatedMessage
 }
 
-func init() {
+func init() { xxx_File_test_test_proto_init() }
+func xxx_File_test_test_proto_init() {
+	if File_test_test_proto != nil {
+		return
+	}
+	xxx_File_test_test_import_proto_init()
+	xxx_File_test_test_public_proto_init()
+	xxx_File_test_test_weak_proto_init()
 	messageTypes := make([]protoreflect.MessageType, 30)
 	extensionTypes := make([]protoreflect.ExtensionType, 37)
 	File_test_test_proto = protoimpl.FileBuilder{

+ 5 - 1
internal/testprotos/test/test_import.pb.go

@@ -129,7 +129,11 @@ var xxx_File_test_test_import_proto_goTypes = []interface{}{
 }
 var xxx_File_test_test_import_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_test_test_import_proto_init() }
+func xxx_File_test_test_import_proto_init() {
+	if File_test_test_import_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_test_test_import_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_test_test_import_proto_rawdesc,

+ 5 - 1
internal/testprotos/test/test_public.pb.go

@@ -80,7 +80,11 @@ var xxx_File_test_test_public_proto_goTypes = []interface{}{
 }
 var xxx_File_test_test_public_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_test_test_public_proto_init() }
+func xxx_File_test_test_public_proto_init() {
+	if File_test_test_public_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_test_test_public_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_test_test_public_proto_rawdesc,

+ 5 - 1
internal/testprotos/test/test_weak.pb.go

@@ -80,7 +80,11 @@ var xxx_File_test_test_weak_proto_goTypes = []interface{}{
 }
 var xxx_File_test_test_weak_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_test_test_weak_proto_init() }
+func xxx_File_test_test_weak_proto_init() {
+	if File_test_test_weak_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_test_test_weak_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_test_test_weak_proto_rawdesc,

+ 5 - 1
reflect/protoregistry/testprotos/test.pb.go

@@ -448,7 +448,11 @@ var xxx_File_test_proto_depIdxs = []int32{
 	0, // testprotos.Message4.enum_field:type_name -> testprotos.Enum1
 }
 
-func init() {
+func init() { xxx_File_test_proto_init() }
+func xxx_File_test_proto_init() {
+	if File_test_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 4)
 	extensionTypes := make([]protoreflect.ExtensionType, 6)
 	File_test_proto = protoimpl.FileBuilder{

+ 5 - 1
types/descriptor/descriptor.pb.go

@@ -2914,7 +2914,11 @@ var xxx_File_google_protobuf_descriptor_proto_depIdxs = []int32{
 	9,  // google.protobuf.DescriptorProto.ExtensionRange.options:type_name -> google.protobuf.ExtensionRangeOptions
 }
 
-func init() {
+func init() { xxx_File_google_protobuf_descriptor_proto_init() }
+func xxx_File_google_protobuf_descriptor_proto_init() {
+	if File_google_protobuf_descriptor_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 27)
 	File_google_protobuf_descriptor_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_descriptor_proto_rawdesc,

+ 5 - 1
types/known/any.pb.go

@@ -213,7 +213,11 @@ var xxx_File_google_protobuf_any_proto_goTypes = []interface{}{
 }
 var xxx_File_google_protobuf_any_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_google_protobuf_any_proto_init() }
+func xxx_File_google_protobuf_any_proto_init() {
+	if File_google_protobuf_any_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_google_protobuf_any_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_any_proto_rawdesc,

+ 7 - 1
types/known/api.pb.go

@@ -469,7 +469,13 @@ var xxx_File_google_protobuf_api_proto_depIdxs = []int32{
 	5, // google.protobuf.Method.syntax:type_name -> google.protobuf.Syntax
 }
 
-func init() {
+func init() { xxx_File_google_protobuf_api_proto_init() }
+func xxx_File_google_protobuf_api_proto_init() {
+	if File_google_protobuf_api_proto != nil {
+		return
+	}
+	xxx_File_google_protobuf_source_context_proto_init()
+	xxx_File_google_protobuf_type_proto_init()
 	messageTypes := make([]protoreflect.MessageType, 3)
 	File_google_protobuf_api_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_api_proto_rawdesc,

+ 5 - 1
types/known/duration.pb.go

@@ -175,7 +175,11 @@ var xxx_File_google_protobuf_duration_proto_goTypes = []interface{}{
 }
 var xxx_File_google_protobuf_duration_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_google_protobuf_duration_proto_init() }
+func xxx_File_google_protobuf_duration_proto_init() {
+	if File_google_protobuf_duration_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_google_protobuf_duration_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_duration_proto_rawdesc,

+ 5 - 1
types/known/empty.pb.go

@@ -96,7 +96,11 @@ var xxx_File_google_protobuf_empty_proto_goTypes = []interface{}{
 }
 var xxx_File_google_protobuf_empty_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_google_protobuf_empty_proto_init() }
+func xxx_File_google_protobuf_empty_proto_init() {
+	if File_google_protobuf_empty_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_google_protobuf_empty_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_empty_proto_rawdesc,

+ 5 - 1
types/known/field_mask.pb.go

@@ -303,7 +303,11 @@ var xxx_File_google_protobuf_field_mask_proto_goTypes = []interface{}{
 }
 var xxx_File_google_protobuf_field_mask_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_google_protobuf_field_mask_proto_init() }
+func xxx_File_google_protobuf_field_mask_proto_init() {
+	if File_google_protobuf_field_mask_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_google_protobuf_field_mask_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_field_mask_proto_rawdesc,

+ 5 - 1
types/known/source_context.pb.go

@@ -100,7 +100,11 @@ var xxx_File_google_protobuf_source_context_proto_goTypes = []interface{}{
 }
 var xxx_File_google_protobuf_source_context_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_google_protobuf_source_context_proto_init() }
+func xxx_File_google_protobuf_source_context_proto_init() {
+	if File_google_protobuf_source_context_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_google_protobuf_source_context_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_source_context_proto_rawdesc,

+ 5 - 1
types/known/struct.pb.go

@@ -397,7 +397,11 @@ var xxx_File_google_protobuf_struct_proto_depIdxs = []int32{
 	2, // google.protobuf.Struct.FieldsEntry.value:type_name -> google.protobuf.Value
 }
 
-func init() {
+func init() { xxx_File_google_protobuf_struct_proto_init() }
+func xxx_File_google_protobuf_struct_proto_init() {
+	if File_google_protobuf_struct_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 4)
 	File_google_protobuf_struct_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_struct_proto_rawdesc,

+ 5 - 1
types/known/timestamp.pb.go

@@ -194,7 +194,11 @@ var xxx_File_google_protobuf_timestamp_proto_goTypes = []interface{}{
 }
 var xxx_File_google_protobuf_timestamp_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_google_protobuf_timestamp_proto_init() }
+func xxx_File_google_protobuf_timestamp_proto_init() {
+	if File_google_protobuf_timestamp_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 1)
 	File_google_protobuf_timestamp_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_timestamp_proto_rawdesc,

+ 7 - 1
types/known/type.pb.go

@@ -783,7 +783,13 @@ var xxx_File_google_protobuf_type_proto_depIdxs = []int32{
 	9, // google.protobuf.Option.value:type_name -> google.protobuf.Any
 }
 
-func init() {
+func init() { xxx_File_google_protobuf_type_proto_init() }
+func xxx_File_google_protobuf_type_proto_init() {
+	if File_google_protobuf_type_proto != nil {
+		return
+	}
+	xxx_File_google_protobuf_any_proto_init()
+	xxx_File_google_protobuf_source_context_proto_init()
 	messageTypes := make([]protoreflect.MessageType, 5)
 	File_google_protobuf_type_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_type_proto_rawdesc,

+ 5 - 1
types/known/wrappers.pb.go

@@ -519,7 +519,11 @@ var xxx_File_google_protobuf_wrappers_proto_goTypes = []interface{}{
 }
 var xxx_File_google_protobuf_wrappers_proto_depIdxs = []int32{}
 
-func init() {
+func init() { xxx_File_google_protobuf_wrappers_proto_init() }
+func xxx_File_google_protobuf_wrappers_proto_init() {
+	if File_google_protobuf_wrappers_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 9)
 	File_google_protobuf_wrappers_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_wrappers_proto_rawdesc,

+ 5 - 1
types/plugin/plugin.pb.go

@@ -420,7 +420,11 @@ var xxx_File_google_protobuf_compiler_plugin_proto_depIdxs = []int32{
 	3, // google.protobuf.compiler.CodeGeneratorResponse.file:type_name -> google.protobuf.compiler.CodeGeneratorResponse.File
 }
 
-func init() {
+func init() { xxx_File_google_protobuf_compiler_plugin_proto_init() }
+func xxx_File_google_protobuf_compiler_plugin_proto_init() {
+	if File_google_protobuf_compiler_plugin_proto != nil {
+		return
+	}
 	messageTypes := make([]protoreflect.MessageType, 4)
 	File_google_protobuf_compiler_plugin_proto = protoimpl.FileBuilder{
 		RawDescriptor:      xxx_File_google_protobuf_compiler_plugin_proto_rawdesc,