A simple Golang implementation of a Quiz that:
- asks a user simple maths questions
- validates their answer
- computes their % correct answer
- times the user in between questions
- sources both the question and answers from a CSV file
The code leverages channels/go-routines alongside the following:
flags
packagecsv
packageos
packagetime
packagereflect
packagestrings
package
Make sure you are within your local Golang work environment, then run the following:
$ git clone [email protected]:damilarelana/goQuiz.git
$ cd goQuiz
$ go build . && ./goQuiz
The original quiz data is stored as quizData.csv
. Its data content/filename can be changed. If the quiz data content/filename is changed, then proceed to use the csv
flag to re-run using the following:
$ ./goQuiz -csv="<newFileName.csv>"
where <newFileName.csv>
refers to the full-path for the new quiz data content/filename.
The limit
flag can be use to adjust the countdown timer (in seconds
) for each question i.e. the quiz would end if the user does not supply an answer within a time limit. Currently, the default value is 30
i.e. 30 seconds
. To change the countdown timer, run the code with the desired limit flag value e.g. :
$ ./goQuiz -limit="45"
where 45
means the user now has 45 seconds
to answer each question.