-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Is your feature request related to a problem? Please describe.
In the google-cloud-go generated libraries, a single client imports a variety of modules. Some of these modules have the same package name (e.g. google.golang.org/grpc
and google.golang.org/api/transport/grpc
). In the code generator for these libraries, which is implemented as a protoc plugin (using the github.com/golang/protobuf v1 lib + a bunch of hand written helpers), we alias some of these conflicting imports (e.g. google.golang.org/grpc
is referenced normally as grpc
, while google.golang.org/api/transport/grpc
is aliased to gtransport
) in the generated code.
I've been looking to migrate the google-cloud-go client library generator to the google.golang.org/protobuf/compiler/protogen
lib, but found the inability to alias the imports of a GeneratedFile
to be a not ideal. Using the same example, we get google.golang.org/api/transport/grpc
aliased as grpc2
.
I'd like to be able to generate the exact same code I could using the v1 plugin lib, but without using some of the custom libs we've written that are made mostly redundant by the new protogen
APIs.
Describe the solution you'd like
I think it would be valuable to allow aliasing imports of a GeneratedFile
to give code generator authors more flexibility where the default behavior of protogen
import naming is not ideal.
Describe alternatives you've considered
I will continue using the hand-spun Go import management code we've used and directly write the import
block to the GeneratedFile
.
If I misunderstood how to use the import APIs, please let me know! Thanks for the consideration.