viaramb / go-employee

Clean architecture in Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-employee

Clean architecture in Go.

Based on the learnings from the book Get Your Hands Dirty on Clean Architecture by Tom Hombergs

testing

requires docker and make

unit tests with code coverage:
TEST_PG_HOST=localhost TEST_PG_PORT=5432 TEST_PG_USER=postgres TEST_PG_PASSWORD=testpwd TEST_PG_DBNAME=postgres make test

integration tests with code coverage:
TEST_PG_HOST=localhost TEST_PG_PORT=5432 TEST_PG_USER=postgres TEST_PG_PASSWORD=testpwd TEST_PG_DBNAME=postgres make test-integration

run

requires docker and postgres

docker build . -t rubinthomasdev/go-employee:latest

for postgres running on windows host
docker run -p 8080:8080 -e PG_HOST=host.docker.internal -e PG_PORT=5432 -e PG_USER=postgres -e PG_PASSWORD=yourpgpassword -e PG_DBNAME=postgres --name employeeapi rubinthomasdev/go-employee:latest

for postgres running on mac host
docker run -p 8080:8080 -e PG_HOST=docker.for.mac.localhost -e PG_PORT=5432 -e PG_USER=postgres -e PG_PASSWORD=yourpgpassword -e PG_DBNAME=postgres --name employeeapi rubinthomasdev/go-employee:latest

endpoints:

to get all employees data:

curl --location --request GET 'localhost:8080/api/v1/employees' \
--header 'Content-Type: application/json'

to get a single employees data:

curl --location --request GET 'localhost:8080/api/v1/employees/1' \
--header 'Content-Type: application/json'

About

Clean architecture in Go.

License:MIT License


Languages

Language:Go 97.4%Language:Makefile 1.7%Language:Dockerfile 0.9%