mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2024-12-28 00:19:55 +00:00
1fa8ab0ed5
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>
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
// 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.
|
|
|
|
// The protoc-gen-go binary is a protoc plugin to generate a Go protocol
|
|
// buffer package.
|
|
package main
|
|
|
|
import (
|
|
"errors"
|
|
"flag"
|
|
|
|
gengo "github.com/golang/protobuf/v2/cmd/protoc-gen-go/internal_gengo"
|
|
"github.com/golang/protobuf/v2/protogen"
|
|
)
|
|
|
|
func main() {
|
|
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
|
|
}
|
|
filename := f.GeneratedFilenamePrefix + ".pb.go"
|
|
g := gen.NewGeneratedFile(filename, f.GoImportPath)
|
|
gengo.GenerateFile(gen, f, g)
|
|
}
|
|
return nil
|
|
})
|
|
}
|