This repository provides a basic template for building gRPC services in Go. It includes a simple gRPC server and client example, along with a Makefile for easy management of the build process.
.
├── api
│ └── helloworld.go # Generated gRPC code
├── bin # Directory for binaries
├── cmd
│ ├── client
│ │ └── main.go # gRPC client implementation
│ └── server
│ └── main.go # gRPC server implementation
├── compile_proto.sh # Script to compile protobuf files
├── go.mod # Go module file
├── go.sum # Go dependencies file
├── grpc
│ ├── helloworld # Generated gRPC code
│ ├── helloworld_grpc.pb.go
│ └── helloworld.pb.go
├── LICENSE # License file
├── Makefile # Makefile for build automation
├── proto
│ └── helloworld.proto # Protobuf file
└── README.md # This README file
- Go 1.16 or higher
- Protocol Buffers compiler (
protoc
) - Go plugins for
protoc
Follow the installation guide for protoc
.
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
Make sure $GOPATH/bin is in your PATH.
Use the compile_proto.sh script to compile the protobuf files:
make proto
Use the Makefile to build the server and client binaries.
make build
./bin/server
./bin/client
- proto/helloworld.proto: Protobuf definition for the helloworld service.
- grpc/helloworld: Generated Go code for the helloworld service.
- cmd/server/main.go: Entrypoint of the gRPC server.
- cmd/client/main.go: Entrypoint of the gRPC client.
- compile_proto.sh: Script to compile protobuf files.
- Makefile: Makefile to automate the build process.
This project is licensed under the MIT License - see the LICENSE file for details.
- gRPC
- Protocol Buffers