golotteryservice

command module
v0.0.0-...-a388b5a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 2 Imported by: 0

README

golotteryservice

A WebApi using the Go Fiber webframework to generate lottery numbers for use in various lottery games - written in 100% Go.

Build Status

This project contains:

Installation

The toolchain is mainly driven by the Makefile.

help          - Display help about make targets for this Makefile
localrelease  - Builds the project in preparation for (local)release
docs          - updates the swagger docs
debug         - Builds the project in preparation for debug
buildandrun   - builds and runs the program on the target platform
run           - runs main.go for testing
clean         - Remove the old builds and any debug information
unittest      - executes unit tests
dep           - fetches any external dependencies
vet           - Vet examines Go source code and reports suspicious constructs
staticcheck   - Runs static code analyzer staticcheck - currently broken
seccheck      - Code vulnerability check
lint          - format code and tidy modules
depupdate     - Update dependencies

Setup/Configuration

This API is secured via an API key which is set in the .env file and is passed in the request header to the API as XApiKey. Make sure to not commit the key to your public repository. Refer to the file .env.example for help. You will need to set this prior to running the API, otherwise you will get this error. missing or malformed API Key.

Usage

From the command line the usage is pretty simple: All values are integers unless specified.

make run

curl http://localhost:8080/lottery?maxgames='<Max games value>'&randnum='<Random number value>;&maxnumspergame='<Max numbers per game value>'

Results will be returned as JSON, for example:

[
  "Game: 1 - [87 90 56 7 37 4 71]",
  "Game: 2 - [90 88 47 84 45 23 32]",
  "Game: 3 - [76 26 38 43 18 1 30]",
  "Game: 4 - [28 90 64 81 60 44 76]",
  "Game: 5 - [71 58 30 13 19 20 40]",
  "Game: 6 - [83 51 87 3 7 19 88]",
  "Game: 7 - [76 26 32 39 79 53 66]",
  "Game: 8 - [85 61 32 17 34 21 48]",
  "Game: 9 - [55 70 9 59 86 45 54]",
  "Game: 10 - [36 32 7 2 16 73 58]"
]
Docker Support

This project has been fully tested with Docker and includes a Dockerfile and a docker-compose.yml file and uses a multi-stage docker file to reduce the docker image to approx. 30MB. The docker build process also optimises the Go executable down to a bare minimum. To build the docker image type:

docker build -t golotteryservice:1.0.0 .

and to run the comtainer type:

docker run -p 8080:8080 golotteryservice:1.0.0

or you can streamline the container build and run process by typing:

docker compose up

and to tear it down type:

docker compose down

Issues

Please feel free to lodge an issue or pull request on GitHub.

Known Issues/Bugs

  • None at this stage

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL