This is a boilerplate to start a Golang API project using echo web framework.
- Makefile
- Devcontainer
- Clone this repo.
- Open the repo using
vscode
. - Open the folder in devcontainer (vscode: F1 > Dev Containers: Rebuild and Reopen in Container)
- Edit
rename-module.sh
and replaceNEW_MODULE_NAME
with your project name. - Run
rename-module.sh
to rename the module name. - Copy
.env
in place & start usingmake
cp ./config/.env.example .env
make dev
The API server should be running at http://localhost:8080
. Verify it using curl
curl http://localhost:8080/user/1
# {"ID":1,"CreatedAt":"2024-02-06T10:00:49.4952092+08:00","UpdatedAt":"2024-02-06T10:00:49.4952092+08:00","DeletedAt":"0001-01-01T00:00:00Z","Username":"test","Email":"[email protected]"}
charmbracelet/log was used to enable pretty & coloured printing during development.
Set ENV
variable as production
to enable logging in JSON format.
Variable | Description |
---|---|
ENV | development/production, default: development |
SERVER_HOST | run on which interface, default: localhost |
SERVER_PORT | run on which port, default: 8080 |