protogen: add an option to rewrite import paths
This allows us to implement the import_prefix parameter in the v1
protoc-gen-go.
Drop support for import_prefix in protogen, and explicitly produce an
error if it is used in the v2 protoc-gen-go.
Change-Id: I66136b6b3affa3c0e9a93dc565619c90c42c0ecc
Reviewed-on: https://go-review.googlesource.com/138257
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/cmd/protoc-gen-go/main.go b/cmd/protoc-gen-go/main.go
index efd294b..8c72be8 100644
--- a/cmd/protoc-gen-go/main.go
+++ b/cmd/protoc-gen-go/main.go
@@ -15,15 +15,21 @@
)
func main() {
- var flags flag.FlagSet
- plugins := flags.String("plugins", "", "deprecated option")
- opts := &protogen.Options{
- ParamFunc: flags.Set,
- }
+ var (
+ flags flag.FlagSet
+ plugins = flags.String("plugins", "", "deprecated option")
+ importPrefix = flags.String("import_prefix", "", "deprecated option")
+ opts = &protogen.Options{
+ ParamFunc: flags.Set,
+ }
+ )
protogen.Run(opts, func(gen *protogen.Plugin) error {
if *plugins != "" {
return errors.New("protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC")
}
+ if *importPrefix != "" {
+ return errors.New("protoc-gen-go: import_prefix is not supported")
+ }
for _, f := range gen.Files {
if !f.Generate {
continue