package
0.0.0-20210510044125-d944f765a1e2
Repository: https://github.com/rajch/contacts.git
Documentation: pkg.go.dev

# README

grpc

Package grpc is a very simple introduction to creating a GRPC API definition using a .proto file and generating code for it using the protoc compiler.

Setting up protoc and Go code generators

The protoc compiler can be downloaded from https://github.com/protocolbuffers/protobuf/releases/.

We need to install two Go plugins, which generate Go structs for protocol buffer messages and scaffolding for a GRPC server and client respectively. This can be done by running the following command:

go get google.golang.org/protobuf/cmd/protoc-gen-go \
       google.golang.org/grpc/cmd/protoc-gen-go-grpc

This command will install the relevant executables to either $GOBIN or ${GOPATH}/bin. The directory should be on your PATH for the protoc compiler to find them.

Generating core from the .proto file

The following command will generate both the structs and the scaffolding.

protoc --go_out=. --go_opt=paths=source_relative \
       --go-grpc_out=. --go-grpc_opt=paths=source_relative \
       contacts.proto

This will generate Go source files in the same directory. The file contacts.pb.go will contain structs derived from the messages defined in the .proto file. The file contacts_grpc.pb.go will contain a fully implemented GRPC client for the service defined in the .proto file. It will also contain scaffolding for implementing a GRPC server for the service, notably an interface that has to be implemented when writing the actual GRPC server.

# Functions

No description provided by the author
No description provided by the author

# Variables

ContactService_ServiceDesc is the grpc.ServiceDesc for ContactService service.
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
UnimplementedContactServiceServer must be embedded to have forward compatible implementations.

# Interfaces

No description provided by the author
No description provided by the author
ContactServiceClient is the client API for ContactService service.
ContactServiceServer is the server API for ContactService service.
UnsafeContactServiceServer may be embedded to opt out of forward compatibility for this service.