README ¶
Go REST API Boilerplate
This is a boilerplate project for building a Modular REST API in Go, aimed to speed up the process of starting a new project and structuring the app.
It uses the following major libraries:
- fiber - Web Framework: https://github.com/gofiber/fiber
- sqlx - Database Access Layer: https://github.com/jmoiron/sqlx
- pq - PostgreSQL Driver: https://github.com/lib/pq
- go-json - JSON Serialization: https://github.com/goccy/go-json
- validator - Request Validation: https://github.com/go-playground/validator
Usage
Make sure to refactor the go module in go.mod
with your corresponding module.
A .env.example
file is provided in the root directory. Copy it to .env
and adjust the values to your needs.
# App
APP_DEBUG=
APP_PORT=
# Database
DB_DSN="database://user:password@host:port/dbname?sslmode=&TimeZone="
DB_CONN_OPEN=
DB_CONN_IDLE=
DB_CONN_LIFETIME=
To initialize new modules, run the following command:
go run scripts/module.go <module name>
To initialize new submodules, run the following command:
go run scripts/submodule.go <module name> <submodule name>
To run the app, execute the following command:
go run cmd/app/main.go
Click to show internal directories.
Click to hide internal directories.