/go-boilerplate

REST API boilerplate built with go and clean architecture - Echo Framework

Primary LanguageGoMIT LicenseMIT

GO Boilerplate

Go Reference License: MIT Go Report Card

Prerequisite

Install go-migrate for running migration

https://github.com/golang-migrate/migrate

App requires 2 database (postgreSQL and redis server), run from your local machine or run it using docker with the following command

# run postgreSQL
docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=go-boilerplate postgres

# run redis
docker run -d -p 6379:6379 redis

Migration

Run below command to run migration

migrate -path migration -database "${DATABASE_URL}" up

To create a new migration file

migrate create -ext sql -dir migration -seq name

Test

Run below command to run test, and make sure that all tests are passing

go test -v ./...

Running

Run below command to run app

go run ./cmd/api/main.go

You can find usefull commands in Makefile.