2018-09-24 20:43:03 +00: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 22:26:33 +00:00
|
|
|
"errors"
|
|
|
|
"flag"
|
|
|
|
|
|
|
|
gengo "github.com/golang/protobuf/v2/cmd/protoc-gen-go/internal_gengo"
|
|
|
|
"github.com/golang/protobuf/v2/protogen"
|
2018-09-24 20:43:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-09-27 22:51:05 +00: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 22:26:33 +00: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 22:51:05 +00:00
|
|
|
if *importPrefix != "" {
|
|
|
|
return errors.New("protoc-gen-go: import_prefix is not supported")
|
|
|
|
}
|
2018-09-27 22:26:33 +00:00
|
|
|
for _, f := range gen.Files {
|
2019-02-28 05:46:29 +00:00
|
|
|
if f.Generate {
|
|
|
|
gengo.GenerateFile(gen, f)
|
2018-09-27 22:26:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
2018-09-24 20:43:03 +00:00
|
|
|
}
|