Installation
Let's get you started quickly. This page is aimed to get you up and running from scratch.
Native
- Clone this repository
git clone git@github.com:codoworks/go-boilerplate.git
- Run
cd go-boilerplate
- Run
go get
to install dependencies - Run
go run . db migrate
to create the database schema - Run
go run . db seed
to seed the DB with initial data - Run
go run . start
to start the server, you should see the following:
Service Output
...
⇨ http server started on [::]:8081
⇨ http server started on [::]:8080
⇨ http server started on [::]:8079
- List available routes using
go run . info public-api-routes
and use your favourite API client to test. or use the following to get started and make sure you're up and running.
Example curl commands
curl -H "Accept: application/json" http://127.0.0.1:8081/health/alive
curl -H "Accept: application/json" http://127.0.0.1:8081/health/ready
Recommended: run go run .
and explore all available options, it should be straightforward.
Docker
The service is shipped with a few Docker compose files to get you started, all of which are automated with a Makefile to make things consistent.
Quick Start
From the boilerplate root folder, run the quick-start target from the Makefile.
make quick-start
Quick Start with MySQL
To run an example using MySQL database, from the boilerplate root folder, run the quick-start-mysql target from the Makefile.
make quick-start-mysql
Quick Start with Postgres
To run an example using Postgres database, from the boilerplate root folder, run the quick-start-mysql target from the Makefile.
make quick-start-postgres
Finally, you can test the service using the same curl commands as above, make sure to change the port to 8081.
Example curl commands
curl -H "Accept: application/json" http://127.0.0.1:8081/health/alive
curl -H "Accept: application/json" http://127.0.0.1:8081/health/ready