Skip to content

Project created for learning purposes and is a lucky random number generator for Mega Sena.

License

Notifications You must be signed in to change notification settings

hiago-balbino/random-luck

Repository files navigation

License: MIT Go Reference Go Report Card Linter Security Tests

🍀 RANDOM LUCK

This project was created for learning purposes and is a lucky random number generator for Mega Sena.

Some tools used do not represent the best choice, they were only used for learning purposes. For example the application can be run as a Command Line or it can be run as a Web where the template package was used.

🧰 Dependencies

🛠️ Useful commands

You can run the command below to see all the useful commands available and your goals.

make help

⚙️ Running the Application

Command Line

You can install the application using go install.

go install github.com/hiago-balbino/random-luck/v2/cmd/luckctl@latest

Then you can run the application using luckctl. Note that if you want to run anywhere you need to export the $GOPATH/bin/luckctl to your $PATH environment variables.

luckctl --games=2 --numbers=6

If you prefer can just run make run-ctl.

make run-ctl games=2 numbers=6

Web

To run the project locally you need to export some environment variables and this can be done using direnv. You can export the variables below.

NGINX_PORT='80'
LOG_LEVEL='ERROR'

After exporting the environment variables, you can run the make compose-up command and the application will run on Docker.

  • The application will be accessible at http://localhost/index and the parameters need to be filled in and you will do this by following the HTML form:
    • amount_of_games (must be greater than zero)
    • amount_of_numbers_per_game (must be greater than or equal to six and less than or equal to nine)

If you prefer to run outside of docker, just run make run-web (accessible at http://localhost:8888/index).

🪲 Debugging

  • If you want to debug the application, in your IDE you need to run the main file inside the cmd/luckweb or cmd/luckctl directory.

📜 Running Internal Documentation

You can do this by running the make doc command and going to the address http://localhost:6060.

📊 Runtime metrics

In the Web application you can view real-time Go program runtime metrics data in your browser at http://localhost/metrics or http://localhost:8888/metrics(when running locally).

  • Heap (global)
  • Heap (details)
  • Live Objects in Heap
  • Live Bytes in Heap
  • MSpan/MCache
  • Goroutines
  • Size Classes
  • Stop-the-world Pause Latencies
  • Time Goroutines Spend in 'Runnable'
  • Starting Size of Goroutines Stacks
  • Goroutine Scheduling Events
  • CGO Calls

🎯 How to run sonarqube locally

The project is set up to run sonarqube locally and has three commands in the Makefile. The sonarqube will be downloaded by Docker, but you need to install sonar-scanner following your operating system.

To run sonarqube locally, you need to export the following environment variables. You can do this using direnv.

SONAR_PORT='9000'
SONAR_HOST='http://localhost:9000'
SONAR_LOGIN='admin'
SONAR_PASSWORD='admin'
SONAR_BINARY='Here you need to fill it according to your operational system. Example: sonar-scanner for Linux/MacOS or sonar-scanner.bat for Windows'

After installing and configuring sonar-scanner in $PATH(if needed) you will be able to run the commands below. By running the make sonarqube-up and make sonarqube-analysis commands you can open the http://localhost:9000 address in your browser and login and password as admin(perhaps sonarqube may prompt you to change your password).

sonarqube-up: start sonarqube container
sonarqube-analysis: run sonar scanner
sonarqube-down: stop sonarqube container

🤞 Good Luck...