mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2024-12-28 18:25:46 +00:00
2dc6718b59
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>
30 lines
790 B
Bash
Executable File
30 lines
790 B
Bash
Executable File
#!/bin/bash
|
|
# 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.
|
|
|
|
set -e
|
|
|
|
# Install the working tree's protoc-gen-gen in a tempdir.
|
|
tmpdir=$(mktemp -d -t protobuf-regen.XXXXXX)
|
|
trap 'rm -rf $tmpdir' EXIT
|
|
mkdir -p $tmpdir/bin
|
|
PATH=$tmpdir/bin:$PATH
|
|
GOBIN=$tmpdir/bin go install ./cmd/protoc-gen-go
|
|
GOBIN=$tmpdir/bin go install ./cmd/protoc-gen-go-grpc
|
|
|
|
# Generate various test protos.
|
|
PROTO_DIRS=(
|
|
cmd/protoc-gen-go/testdata
|
|
cmd/protoc-gen-go-grpc/testdata
|
|
)
|
|
for dir in ${PROTO_DIRS[@]}; do
|
|
for p in `find $dir -name "*.proto"`; do
|
|
echo "# $p"
|
|
protoc -I$dir \
|
|
--go_out=paths=source_relative:$dir \
|
|
--go-grpc_out=paths=source_relative:$dir \
|
|
$p
|
|
done
|
|
done
|