Simple example of a CRUD app in go.
To run you need docker and docker-compose installed.
- go 1.11+
- PostgreSQL 9.5
- dbmate database migration tool.
-
Clone this git repo to your go path. e.g. go/src/github/
git clone https://github.com/daesu/payments
-
Run as docker container
make docker-run
Postgresql and the App will be run in docker containers.
Documentation is autogenerated from swagger and available at localhost:8080/v1/docs
- Clone this git repo to your go path. e.g. go/src/github/
git clone https://github.com/daesu/payments
-
Set environment variables.
DATABASE_HOST=<postgres host> DATABASE_USERNAME=<postgres username> DATABASE_PASSWORD=<postgres password> DATABASE_NAME=<postgres db name>
LOG_LEVEL
Optional. Can be set to info, debug, error, fatalDATABASE_URL=<postgres connection string>
e.g. postgresql://$DATABASE_USERNAME:$DATABASE_PASSWORD@$DATABASE_HOST/$DATABASE_NAME?sslmode=disable
Can be set from the included env
file with source ./env
- Create & Seed database
./db/migration.sh
- Install deps
make init
- Build
make build
- Run
make run
Server will be started at localhost:8080
Tests require access to a postgres db with the following env variables set.
DATABASE_HOST=<postgres host>
DATABASE_USERNAME=<postgres username>
DATABASE_PASSWORD=<postgres password>
To run the tests;
make tests
This will setup a test database, run migrations, seed some data, run the app, and run the tests.