README

gRPC in 3 minutes (Go)

BACKGROUND

For this sample, we've already generated the server and client stubs from helloworld.proto.

PREREQUISITES

$ go help gopath
$ # ensure the PATH contains $GOPATH/bin
$ export PATH=$PATH:$GOPATH/bin

INSTALL

$ go get -u google.golang.org/grpc/examples/helloworld/greeter_client
$ go get -u google.golang.org/grpc/examples/helloworld/greeter_server

TRY IT!

  • Run the server

    $ greeter_server &
    
  • Run the client

    $ greeter_client
    

OPTIONAL - Rebuilding the generated code

  1. Install protobuf compiler

  2. Install the protoc Go plugin

    $ go get -u github.com/golang/protobuf/protoc-gen-go
    
  3. Rebuild the generated Go code

    $ go generate google.golang.org/grpc/examples/helloworld/...
    

    Or run protoc command (with the grpc plugin)

    $ protoc -I helloworld/ helloworld/helloworld.proto --go_out=plugins=grpc:helloworld
    
Expand ▾ Collapse ▴

Directories

Path Synopsis
features/authentication/client The client demonstrates how to supply an OAuth2 token for every RPC.
features/authentication/server The server demonstrates how to consume and validate OAuth2 tokens provided by clients for each RPC.
features/cancellation/client Binary client is an example client.
features/cancellation/server Binary server is an example server.
features/compression/client Binary client is an example client.
features/compression/server Binary server is an example server.
features/deadline/client Binary client is an example client.
features/deadline/server Binary server is an example server.
features/debugging/client Binary client is an example client.
features/debugging/server Binary server is an example server.
features/encryption/ALTS/client Binary client is an example client.
features/encryption/ALTS/server Binary server is an example server.
features/encryption/TLS/client Binary client is an example client.
features/encryption/TLS/server Binary server is an example server.
features/errors/client Binary client is an example client.
features/errors/server Binary server is an example server.
features/health/client
features/health/server
features/interceptor/client Binary client is an example client.
features/interceptor/server Binary server is an example server.
features/keepalive/client Binary client is an example client.
features/keepalive/server Binary server is an example server.
features/load_balancing/client Binary client is an example client.
features/load_balancing/server Binary server is an example server.
features/metadata/client Binary client is an example client.
features/metadata/server Binary server is an example server.
features/multiplex/client Binary client is an example client.
features/multiplex/server Binary server is an example server.
features/name_resolving/client Binary client is an example client.
features/name_resolving/server Binary server is an example server.
features/profiling/client Binary client is an example client.
features/profiling/server Binary server is an example server.
features/proto Package proto is for go generate.
features/proto/echo
features/reflection/server Binary server is an example server.
features/retry/client Binary client is an example client.
features/retry/server Binary server is an example server.
features/wait_for_ready Binary wait_for_ready is an example for "wait for ready".
features/xds/client Package main implements a client for Greeter service.
features/xds/server Package main starts Greeter service that will response with the hostname.
helloworld/greeter_client Package main implements a client for Greeter service.
helloworld/greeter_server Package main implements a server for Greeter service.
helloworld/helloworld
helloworld/mock_helloworld
route_guide/client Package main implements a simple gRPC client that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
route_guide/mock_routeguide
route_guide/routeguide
route_guide/server Package main implements a simple gRPC server that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.