- Clone repository
git clone https://github.com/brain-flowing-company/psuechaokhai-backend.git- Start backend server
docker-compose up -d --build --no-deps # note: frontend only- pgAdmin is available at localhost:5050
| Field | Value |
|---|---|
| pgAdmin Username | [email protected] |
| pgAdmin Password | admin |
| Host name/address | db |
| Port | 5432 |
| Username | postgres |
| Password | 123456 |
Prerequisite
- Golang
- Makefile (optional)
- docker
- git
- swagger
- Clone repository
git clone https://github.com/brain-flowing-company/psuechaokhai-backend.git-
Copy
.env.exampleto.env -
Get Swagger cli
go install github.com/swaggo/swag/cmd/swag@latest- Run development server
docker-compose -f docker-compose.dev.yaml up -d --build --no-deps # note: backend only
# or
make up- pgAdmin is available at localhost:5050
| Field | Value |
|---|---|
| pgAdmin Username | [email protected] |
| pgAdmin Password | admin |
| Host name/address | db |
| Port | 5432 |
| Username | postgres |
| Password | 123456 |
Note: make sure you have
Makefilebefore usingmakecommand
- This will automatically start postgres database and development server with auto-reload.
- Swagger (API docs) is at localhost:8000/docs *change port if your app is running on different port
- If you've made any changes to API docs (comments above handler function), make sure you run this command to update API docs page.
swag init -g ./cmd/main.go -o ./docs/
# or
make docscmd/containsmain.goconfig/contains env var loaderdatabase/contains database (postgres) connectorinternal/- name folder by service name (snake_case)
.handler.gohandles http request.service.goholds core logic.repository.goholds data fetcher (database queries or external api calls)
- Make sure to pull the latest commit from
devbranch
git pull origin dev- Create new branch with your git GUI tools or use this command
git checkout -b <branch-name>- Make sure you on the correct branch
- Craft your wonderful code and don't forget to commit frequently
git add <file-path> # add specific file
# or
git add . # add all filesgit commit -m "<prefix>: <commit message>"Note: check out commit message convention
- Push code to remote repository
- Create pull request on github
- compare changes with base:
dev← compare:<branch-name> - title also apply commit message convention
- put fancy description
git commit -m "<prefix>: <commit message>"- use lowercase
- meaningful commit message
Prefix
feat: introduce new featurefix: fix bugrefactor: changes which neither fix bug nor add a featurechore: changes to the build process or extra tools and libraries