I'm a Golang & gRPC newbie (August 2022). A good way to practice is working on a real opensource project, so I decided to create & work on the book management project with these technologies. If you are a newbie as me, don't hesitate to join me in contribute to this project. If you are an experienced developer, I'm highly appreciate you if you can take a look to the project structure, codebase, etc and give me any feedback on mistakes, good practices, etc. Feel free to create issues or join the project discussion
You can use this project as the template for the following technologies.
- Language: Golang
- API: gRPC
- ORM: Gorm
- Database: PostgreSQL
- Hot reload: Air
You can experiment the project quickly on your local by using docker compose.
$ docker-compose pull
$ docker-compose up -d
You can verify all service up without any error by:
$ docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------------------------------------
book-management-server ./main.out Up 0.0.0.0:8080->8080/tcp,:::8080->8080/tcp
book-management_database-manager_1 entrypoint.sh docker-php-e ... Up 0.0.0.0:9000->8080/tcp,:::9000->8080/tcp
database docker-entrypoint.sh postgres Up 0.0.0.0:5432->5432/tcp,:::5432->5432/tcp
Services:
- book-management-server: gRPC server is listening on port 8080
- database: Postgresql database service
- book-management_database-manager_1: Database management UI service
There is no gRPC client for the project yet. However, you can use Postman to test APIs. Thanks to Postman.
simplescreenrecorder-2022-08-07_16.04.01.mp4
- Install hot reload tool: https://github.com/cosmtrek/air
$ make deps
Set the environment varibale DATABASE_DNS
to configure database DNS. For example:
$ DATABASE_DNS=host=localhost user=admin password=admin dbname=book-management port=5432 sslmode=disable TimeZone=Asia/Ho_Chi_Minh
$ make dev
$ make test
$ make run
Copyright (c) 2022-present, Tuan LE CONG