Demonstrate the use of gRPC by generating Protocol Buffers files using commands, enabling bidirectional communication between client and server using pb for efficient interactions.
Note that while this demonstration uses Go, Protocol Buffers support cross-language capabilities.
- Language: Go v1.21.4
- Library: Protocol Buffers v27.2
download Protocol Buffers from GitHub
go get -u && go mod tidy -v
protoc --go_out=. --go-grpc_out=. example.proto
go mod edit -replace greeting-grpc-golang=./..
go get greeting-grpc-golang/pb
- greeting-grpc-golang/server
go run server.go
you will see: 2024/07/09 14:11:12 Starting gRPC server on 50051
- greeting-grpc-golang/client
go run client.go
can get reponse from server: 2024/07/09 14:11:26 Response from server: Hello, Xiong