Installation

Let's get you started quickly. This page is aimed to get you up and running from scratch.

Native

  1. Clone this repository git clone git@github.com:codoworks/go-boilerplate.git
  2. Run cd go-boilerplate
  3. Run go get to install dependencies
  4. Run go run . db migrate to create the database schema
  5. Run go run . db seed to seed the DB with initial data
  6. 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
  1. 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

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

Was this page helpful?

Consider supporting my work if you find it useful

Buy me a coffee