This repository provides a simple example of a gRPC server and client implemented in Go.
- Go installed on your machine
- Protocol Buffers compiler (
protoc
) installed
Install Protocol Buffers Compiler (protoc)
On Linux
sudo apt-get install protobuf-compiler
On macOS
brew install protobuf
On Windows
Download and install from: https://github.com/protocolbuffers/protobuf/releases
-
Clone the repository:
git clone https://github.com/mtmibjas/go-grpc-exe.git cd go-grpc-exe
-
Install dependencies:
go mod tidy
-
Generate Go code from the Protocol Buffers definition:
protoc --go_out=./alerts --go_opt=paths=source_relative --go-grpc_out=./alerts --go-grpc_opt=paths=source_relative alerts.proto
-
Run the gRPC server:
go run server.go
-
Run the gRPC client:
go run client.go
Helpful Commands
go get -u google.golang.org/grpc
go get -u google.golang.org/protobuf
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
Project Structure
alerts.proto
: Protocol Buffers definition file
server.go
: Implementation of the gRPC server
client.go: Implementation of the gRPC client
Customize Feel free to customize the example.proto, server.go, and client.go files to suit your specific requirements. Explore the gRPC documentation for advanced features and configuration options.
Contributing If you find issues or want to contribute to this project, feel free to open a pull request or create an issue.
Replace the placeholder content with the actual content of your example.proto
, server.go
, and client.go
files. Additionally, update the license information and any other details according to your project's requirements.