Categorygithub.com/AidarBabanov/billups-interview
modulepackage
0.0.0-20220320133747-7b6b8d0827b3
Repository: https://github.com/aidarbabanov/billups-interview.git
Documentation: pkg.go.dev

# README

Billups interview question

Coding interview for Billups company.

Service configuration

For the correct service work, you need to use environment variables or the .env file.

In order to use the file, download the godotenv binary file. General command to run .env file:

godotenv -f .env [command]

Environment Variables

VariableDefaultDescription
LOG_LEVELdebugLog level for logger. Possible options: trace, debug, info, warning, error, fatal and panic.
SERVER_PORT8080Port on which app will run.
SERVER_READ_TIMEOUT15sApp read response time.
SERVER_WRITE_TIMEOUT15sApp write response time.

Installation

Manual

You can build the service with the following terminal command:

go build ./cmd/...

Before running the service set up the environment variables and run the app:

# running the app
./app

# with .env file
godotenv -f .env ./app

Docker installation

Installation could be done with docker and docker-compose tools. Set up the environment variables or use .env file.

docker-compose up --build

Testing

Unit-tests are using mocks generated by mockery. Mocks generation commands are embedded in-source using go:generate comments, so before running tests, you need to launch code generation.

# Install mockery tool
go install github.com/vektra/mockery/v2@@v2.10.0

# Run code generation
go generate ./...

# Run unit tests
go test ./...

# with .env file
godotenv -f .env go test ./...

Documentation

Documentation for the REST API is generated with go-swagger tool.

# generating swagger spec
swagger generate spec -o swagger.yml

# serving interactive UI in the browser
swagger serve -F swagger ./swagger.yml

Swagger UI is a graphical representation of swagger specifications. You can access REST documentation with "[base_endpoint]/doc/".

# Packages

No description provided by the author
Package config is responsible for storing configuration data of the application.
No description provided by the author
No description provided by the author
No description provided by the author