Clone this repo and start your API development.
- Please refer .config.json.example
- You can modify .config.json the file or set in Env
- To use config file, duplicate .config.json.example and name it .config.json
- Please correct
db_addr, redis_addr
to run in local.
- Clone this repository
- Build Docker Images
docker-compose build api
- Run Docker Container
docker-compose up api
- Start dependencies
docker-compose up -d db redis
- Start API with serve:
go run main.go serve
- Install https://github.com/codegangsta/gin for live reloading.
Run
gin serve
- Start Redis UI by
docker-compose up -d redis-commander
Open http://localhost:8081 in browser.
- Integrated with PostgreSQL
- Integrated with migration package.
- Run migration:
go run main.go migrate
- Reset migration:
go run main.go migrate --reset
- In order to prevent circular dependency follow the below rules.
api
package can importservice
package.service
can't importapi
.service
package can importdatabase
package. database can't importservice
.- Do not import
database
package directly from api. - Preferred import flow:
api -> services -> database
- HTTP Router - https://github.com/go-chi/chi
- PostgreSQL - https://github.com/jackc/pgx
- Logging - https://github.com/sirupsen/logrus
- JWT Token - https://github.com/dgrijalva/jwt-go
- Cli - https://github.com/spf13/cobra
- Configuration - https://github.com/spf13/viper
- Validation - https://github.com/go-playground/validator
- Redis - https://github.com/go-redis/redis