Simple gRPC chat app with Go
- Go 1.17 or higher
- Protocol Buffers compiler (
protoc) - gRPC
.
├── cmd
│ └── server
│ └── main.go
├── internal
│ └── chat
│ └── chat.go
├── proto
│ └── chat.proto
├── go.mod
└── go.sum
git clone https://github.com/felguerez/grpchat.git
cd grpchatRun from the project root:
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative ./proto/chat.protoRun the following command to download and install the required Go modules:
go mod tidyNavigate to the cmd/server directory and run:
go run main.goYou should see a log message indicating that the server is running on port 50051.
You can use grpcurl to manually test the gRPC endpoints:
grpcurl -plaintext -d '{"content": "Hello"}' localhost:50051 chat.ChatService/SendMessage