2018-09-24 13:43:03 -07:00
|
|
|
// 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 (
|
2018-09-27 15:26:33 -07:00
|
|
|
"errors"
|
|
|
|
"flag"
|
|
|
|
|
2019-05-13 23:55:40 -07:00
|
|
|
gengo "google.golang.org/protobuf/cmd/protoc-gen-go/internal_gengo"
|
2019-05-14 12:44:37 -07:00
|
|
|
"google.golang.org/protobuf/compiler/protogen"
|
2018-09-24 13:43:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-09-27 15:51:05 -07:00
|
|
|
var (
|
|
|
|
flags flag.FlagSet
|
|
|
|
plugins = flags.String("plugins", "", "deprecated option")
|
|
|
|
importPrefix = flags.String("import_prefix", "", "deprecated option")
|
|
|
|
opts = &protogen.Options{
|
|
|
|
ParamFunc: flags.Set,
|
|
|
|
}
|
|
|
|
)
|
2018-09-27 15:26:33 -07:00
|
|
|
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")
|
|
|
|
}
|
2018-09-27 15:51:05 -07:00
|
|
|
if *importPrefix != "" {
|
|
|
|
return errors.New("protoc-gen-go: import_prefix is not supported")
|
|
|
|
}
|
2018-09-27 15:26:33 -07:00
|
|
|
for _, f := range gen.Files {
|
2019-02-27 21:46:29 -08:00
|
|
|
if f.Generate {
|
|
|
|
gengo.GenerateFile(gen, f)
|
2018-09-27 15:26:33 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
2018-09-24 13:43:03 -07:00
|
|
|
}
|