The Go REST API Starter Kit is a boilerplate project designed to help you quickly set up and develop RESTful APIs using Go.
- Go (version 1.22.x)
- Postgres 16
- mockery (for mock testing)
-
Create Database
CREATE DATABASE go-rest-api-starter;
-
Run DDL Script
- Execute the DDL script in
migrationdirectory to set up the database schema.
make migrate-up -e DB_HOST=localhost -e DB_PORT=5432 -e DB_NAME=go-rest-api-starter -e DB_USER=postgres -e DB_PASSWORD=postgres
- Execute the DDL script in
-
Configure Environment
- Create environment configuration files in the
envdirectory with the filename format{appname}.{env}.json. Please check the example file.
- Create environment configuration files in the
Make sure to follow Setup section first
-
Build the Project
make build # linux/macThen, run the binary file
bin/go-rest-api-starter -
Run Locally
make run
Run the unit test using:
make testRun the mock (mockery required) using:
make mock