cmd/protoc-gen-go-grpc: add gRPC code generator
This is a straight translation of the v1 API gRPC "plugin" to protogen.
Add a protoc-gen-go-grpc command. The preferred way to generate gRPC
services is to invoke both plugins separately:
protoc --go_out=. --go-grpc_out=. foo.proto
When invoked in this fashion, the generators will produce separate
foo.pb.go and foo_grpc.pb.go files.
Change-Id: Ie180385dab3da7063db96f7c2f9de3abbd749f63
Reviewed-on: https://go-review.googlesource.com/137037
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/cmd/protoc-gen-go-grpc/main.go b/cmd/protoc-gen-go-grpc/main.go
new file mode 100644
index 0000000..238a63a
--- /dev/null
+++ b/cmd/protoc-gen-go-grpc/main.go
@@ -0,0 +1,24 @@
+// 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-grpc binary is a protoc plugin to generate Go gRPC
+// service definitions.
+package main
+
+import (
+ "github.com/golang/protobuf/v2/cmd/protoc-gen-go-grpc/internal_gengogrpc"
+ "github.com/golang/protobuf/v2/protogen"
+)
+
+func main() {
+ protogen.Run(nil, func(gen *protogen.Plugin) error {
+ for _, file := range gen.Files {
+ if !file.Generate {
+ continue
+ }
+ internal_gengogrpc.GenerateFile(gen, file)
+ }
+ return nil
+ })
+}