@@ -38,48 +38,60 @@ func main() {
3838
3939 // Set of generated proto packages to forward to v2.
4040 files := []struct {
41- goPkg string
42- pbDesc protoreflect.FileDescriptor
41+ oldGoPkg string
42+ newGoPkg string
43+ pbDesc protoreflect.FileDescriptor
4344 }{{
44- goPkg : "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor" ,
45- pbDesc : descriptorpb .File_google_protobuf_descriptor_proto ,
45+ oldGoPkg : "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor" ,
46+ newGoPkg : "google.golang.org/protobuf/types/descriptorpb" ,
47+ pbDesc : descriptorpb .File_google_protobuf_descriptor_proto ,
4648 }, {
47- goPkg : "github.com/golang/protobuf/protoc-gen-go/plugin;plugin_go" ,
48- pbDesc : pluginpb .File_google_protobuf_compiler_plugin_proto ,
49+ oldGoPkg : "github.com/golang/protobuf/protoc-gen-go/plugin;plugin_go" ,
50+ newGoPkg : "google.golang.org/protobuf/types/pluginpb" ,
51+ pbDesc : pluginpb .File_google_protobuf_compiler_plugin_proto ,
4952 }, {
50- goPkg : "github.com/golang/protobuf/ptypes/any;any" ,
51- pbDesc : anypb .File_google_protobuf_any_proto ,
53+ oldGoPkg : "github.com/golang/protobuf/ptypes/any;any" ,
54+ newGoPkg : "google.golang.org/protobuf/types/known/anypb" ,
55+ pbDesc : anypb .File_google_protobuf_any_proto ,
5256 }, {
53- goPkg : "github.com/golang/protobuf/ptypes/duration;duration" ,
54- pbDesc : durationpb .File_google_protobuf_duration_proto ,
57+ oldGoPkg : "github.com/golang/protobuf/ptypes/duration;duration" ,
58+ newGoPkg : "google.golang.org/protobuf/types/known/durationpb" ,
59+ pbDesc : durationpb .File_google_protobuf_duration_proto ,
5560 }, {
56- goPkg : "github.com/golang/protobuf/ptypes/timestamp;timestamp" ,
57- pbDesc : timestamppb .File_google_protobuf_timestamp_proto ,
61+ oldGoPkg : "github.com/golang/protobuf/ptypes/timestamp;timestamp" ,
62+ newGoPkg : "google.golang.org/protobuf/types/known/timestamppb" ,
63+ pbDesc : timestamppb .File_google_protobuf_timestamp_proto ,
5864 }, {
59- goPkg : "github.com/golang/protobuf/ptypes/wrappers;wrappers" ,
60- pbDesc : wrapperspb .File_google_protobuf_wrappers_proto ,
65+ oldGoPkg : "github.com/golang/protobuf/ptypes/wrappers;wrappers" ,
66+ newGoPkg : "google.golang.org/protobuf/types/known/wrapperspb" ,
67+ pbDesc : wrapperspb .File_google_protobuf_wrappers_proto ,
6168 }, {
62- goPkg : "github.com/golang/protobuf/ptypes/struct;structpb" ,
63- pbDesc : structpb .File_google_protobuf_struct_proto ,
69+ oldGoPkg : "github.com/golang/protobuf/ptypes/struct;structpb" ,
70+ newGoPkg : "google.golang.org/protobuf/types/known/structpb" ,
71+ pbDesc : structpb .File_google_protobuf_struct_proto ,
6472 }, {
65- goPkg : "github.com/golang/protobuf/ptypes/empty;empty" ,
66- pbDesc : emptypb .File_google_protobuf_empty_proto ,
73+ oldGoPkg : "github.com/golang/protobuf/ptypes/empty;empty" ,
74+ newGoPkg : "google.golang.org/protobuf/types/known/emptypb" ,
75+ pbDesc : emptypb .File_google_protobuf_empty_proto ,
6776 }}
6877
6978 // For each package, construct a proto file that public imports the package.
7079 var req pluginpb.CodeGeneratorRequest
80+ var flags []string
7181 for _ , file := range files {
72- pkgPath := file .goPkg [:strings .IndexByte (file .goPkg , ';' )]
82+ pkgPath := file .oldGoPkg [:strings .IndexByte (file .oldGoPkg , ';' )]
7383 fd := & descriptorpb.FileDescriptorProto {
7484 Name : proto .String (pkgPath + "/" + path .Base (pkgPath ) + ".proto" ),
7585 Syntax : proto .String (file .pbDesc .Syntax ().String ()),
7686 Dependency : []string {file .pbDesc .Path ()},
7787 PublicDependency : []int32 {0 },
78- Options : & descriptorpb.FileOptions {GoPackage : proto .String (file .goPkg )},
88+ Options : & descriptorpb.FileOptions {GoPackage : proto .String (file .oldGoPkg )},
7989 }
8090 req .ProtoFile = append (req .ProtoFile , protodesc .ToFileDescriptorProto (file .pbDesc ), fd )
8191 req .FileToGenerate = append (req .FileToGenerate , fd .GetName ())
92+ flags = append (flags , "M" + file .pbDesc .Path ()+ "=" + file .newGoPkg )
8293 }
94+ req .Parameter = proto .String (strings .Join (flags , "," ))
8395
8496 // Use the internal logic of protoc-gen-go to generate the files.
8597 gen , err := protogen.Options {}.New (& req )
0 commit comments