The protoc compiler is written in C++ and needs to be built from source:
Note: here details shell dependencies required
git clone git@github.com:google/protobuf.git./autogen.sh./configuremake # this can take quite a while ~10 mins for memake check # this can take quite a while ~10 mins for mesudo make installgo get -a github.com/golang/protobuf/protoc-gen-go (Go plugin for protoc compiler)git clone https://github.com/grpc/grpc.gitcd grpc/examplesmkdir testing-helloworldprotoc -I ./protos ./protos/helloworld.proto --go_out=plugins=grpc:testing-helloworldThis generates:
testing-helloworld/
└── helloworld.pb.go
0 directories, 1 file
go get -u google.golang.org/grpc/examples/helloworld/greeter_clientgo get -u google.golang.org/grpc/examples/helloworld/greeter_servercd $GOPATH/src/google.golang.org/grpc/examples/helloworldcd greeter_server & go run main.gocd greeter_client & go run main.goNote: the client/server you downloaded reference their own pb.go
/src/google.golang.org/grpc/examples/helloworld/helloworld/helloworld.pb.go
If you want, you can create your own client/server code to be sure…
cd grpc/examples (wherever you originally git cloned the grpc repo)cp greeter_server.go ./testing-server.goReplace the line:
pb "google.golang.org/grpc/examples/helloworld/helloworld"
With:
pb "github.com/wherever/you/cloned/grpc/examples/testing-helloworld"
Now you should be able to run:
go run testing-server.go
And verify using either the existing Go client you downloaded (see above) or an existing Ruby client (see below).
git clone https://github.com/grpc/grpc.gitcd grpc/examples/rubybundle install (includes install of Ruby plugin for protoc)bundle exec ./greeter_server.rbbundle exec ./greeter_client.rbYou can mix and match servers and clients.
e.g. have a Go server running with a Ruby client connecting, and vice versa
You’ll find that if you want to write your own proto files and compile them, having the protoc compiler itself is not enough. You also need to build grpc (https://github.com/grpc/grpc/blob/master/INSTALL.md) from source too :-/
git clone https://github.com/grpc/grpc.gitcd grpcgit submodule update --initmakemake install