Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ernitingarg/golang-postgres-sqlc-bank-backend
https://github.com/ernitingarg/golang-postgres-sqlc-bank-backend
backend docker-compose gin gin-framework gin-gonic golang makefile postgresql sqlc viper
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ernitingarg/golang-postgres-sqlc-bank-backend
- Owner: ernitingarg
- Created: 2023-11-18T04:03:01.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2023-12-17T02:45:51.000Z (11 months ago)
- Last Synced: 2024-10-01T09:06:51.201Z (about 1 month ago)
- Topics: backend, docker-compose, gin, gin-framework, gin-gonic, golang, makefile, postgresql, sqlc, viper
- Language: Go
- Homepage:
- Size: 106 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Overview
## Prerequisites installation
- Dbeaver Universal database GUI tool: [Download](https://dbeaver.io/download/)
- Make:
- [Download](https://gnuwin32.sourceforge.net/packages/make.htm) or `choco install make`
- `make --version`
- `golang-migrate`:
- [Download](https://github.com/golang-migrate/migrate/tree/master/cmd/migrate)
- `migrate --version`
- `sqlc` (if not to be used as docker)
- [Download](https://docs.sqlc.dev/en/latest/overview/install.html)
- `sqlc version`
- `gomock`:
- [Install] `go install go.uber.org/mock/mockgen@latest`
- `mockgen --version`## Run docker containers locally
To run container, please follow below steps:
- Download docker
- [Windows](https://docs.docker.com/desktop/install/windows-install/)
- [Ubuntu](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository)- Run docker containers
```bash
make start
```- To stop docker containers
```bash
make stop
```- To remove docker containers
```bash
make remove
```- To see containers logs
```bash
make logs_db
make logs_sqlc
```- To connect to Postgres database manually
```bash
docker exec -it postgres bash
psql -U admin -d postgresdb
```- To see all tables in database
```bash
\dt;
```## Migration
- To create migration
```bash
make migrate_create
make migrate_create NAME=init
```- To apply migration
```bash
make migrate_up
make migrate_down
```- Code generation
```bash
Code from db/queries is automatically generated using sqlc docker container which has command `generate`.
```## Server
- To start server
```bash
make server
```## Test
- To generate mock files
```bash
make mock
```- To run unit tests
```bash
make test
```