Skip to content

daesu/payments

Repository files navigation

payments

Simple example of a CRUD app in go.

docker

To run you need docker and docker-compose installed.

dependencies

  • go 1.11+
  • PostgreSQL 9.5
  • dbmate database migration tool.

quick Start

  • 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

Documentation is autogenerated from swagger and available at localhost:8080/v1/docs

local setup

  • 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, fatal

    DATABASE_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

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.

About

Simple example of a CRUD app in go.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published