CRUD example to learn how gRPC works in Go with MongoDB
- Go, follow this official installation guide
- MongoDB, follow this instruction from it's official page
- gRPC, follow this quick start guide for Go specific
- clone this repository
git clone [email protected]:salprima/gocrud-grpc.git
- execute
go mod tidy
to add missing and remove unused modules dependencies - adjust
configs/default-config.yml
according to your local environment - start gRPC server by executing
make run-grpc-server
- if everything okay, you will see something like the following in your terminal
$ make run-grpc-server
go run cmd/grpc-server/main.go
2020/05/25 19:13:26 loading config file default-config.yml
2020/05/25 19:13:26 Starting up GRPC server...
2020/05/25 19:13:26 Creating connection to database...
2020/05/25 19:13:26 Connected to database...
- follow steps 1-3 on How to run gRPC server above
- make sure gRPC server up and running
- run gRPC client by executing
make run-grpc-client
- if all good, you will see log in your terminal simulating all gRPC methods as describe in
api/protobuf/user.proto
- understand how gRPC client & server implementation in Go
- know how MongoDB works within Go using MongoDB Go Driver
- a little example of how Viper works to deal with configuration file
- TIPS: you can run gRPC client using another language you loved, see available quick start guide here
This project is licensed under the MIT License, see the LICENSE file for details.