MicBun / protobuf-golang-todo

A Simple Todo app using Golang, Protocol Buffer, Wire, PostgreSQL, Mockery, Grpc and Docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

protobuf-golang-todo

A Simple Todo app using Golang, Protocol Buffer, Wire, Postgres, Mockery, Grpc, and Docker

Things to Install

  1. Docker Desktop
    1. When using Docker Desktop,you can skip the rest of the steps
  2. Go
  3. Wire
    1. Wire is used for dependency injection
  4. Mockery
    1. Mockery is used for mocking interfaces
  5. Postgres
    1. Postgres is used as the database
  6. gRPC
    1. gRPC is used for communication between services

How to run

Using Docker Compose

  1. Modify .env accordingly
  2. Build the app
docker-compose build
  1. Run the app
docker-compose up

Note: first time running this command will take a while to download the images, but the next time will be faster, also the first time may fail because the app is trying to connect to the database before it is ready, just run the command again and it should work. In case it is still not working, modify the cmd in .air.toml and add a sleep command before running the app (look at the .air2.toml for example)

Using Go run

  1. Setup Local Postgres database
    1. Create database todo
  2. Modify .env file accordingly
  3. Make sure postgres credentials match with your local postgres
  4. Run the app
go run cmd/server/main.go
  1. Tables will be created automatically
  2. Run the client app
go run cmd/client/main.go
  1. It should execute the commands in the cmd/client/main.go file and print the result

Usefully Scripts

Generate Protobuf

sh scripts/protoc.sh

Generate Mocks

sh scripts/mockery.sh

Generate Code Coverage Report

sh scripts/coverage.sh

Generate Wire Dependency Injection

sh scripts/wire.sh

Check all scripts

sh scripts/check_all.sh

About

A Simple Todo app using Golang, Protocol Buffer, Wire, PostgreSQL, Mockery, Grpc and Docker

License:MIT License


Languages

Language:Go 95.6%Language:Shell 3.0%Language:Dockerfile 1.4%