Go handbook Download PDF
GoLang Courses:
Developed at Google and made open source in 2009
It's a multithread language
Designed to run on multiple cores and built to support concurrency
Concurrency in Go is cheap and easy
for performant applications
Docker, Vault, Cockroach is written in Go
GoLang projects: Hello world starter
The problem:
- The task is to build a super simple quiz with a few questions and a few alternatives for each question. With one correct answer per question.
- Backend - Golang
- Database - Just in-memory , so no database
- REST API or gRPC
- CLI that talks with the API, preferably using https://github.com/spf13/cobra ( as cli framework )
- cobra-cli Readme
Installing Cobra
Facing issues with init but go it to work and get the Go project to initialise and run
Testing the application and running "Hello World!"
Package fmt implements formatted I/O with functions analogous to C's printf and scanf. The format 'verbs' are derived from C's but are simpler.
Package io provides basic interfaces to I/O primitives. Its primary job is to wrap existing implementations of such primitives, such as those in package os, into shared public interfaces that abstract the functionality, plus some other related primitives.
Because these interfaces and primitives wrap lower-level operations with various implementations, unless otherwise informed clients should not assume they are safe for parallel execution.
Being able to print in the terminal
Create HTTP Server | http://localhost:3333
Package template (html/template) implements data-driven templates for generating HTML output safe against code injection. It provides the same interface as package text/template and should be used instead of text/template whenever the output is HTML.
Decoding a csv file in go
Trying to run the csv file but there's errors in how I put together the csv structure and questions. code reference
Common Format and MIME Type for Comma-Separated Values (CSV) Files
4 basic range loop (for-each) patterns
Take Input from the User in Golang
Scan function in Golang
The Problem
User stories/Use cases
-
User should be presented questions with a number of answers
-
User should be able to select just one answer per question
-
User should be able to answer all the questions and then post his/her answers and get back how many correct answers there had and be displayed to the user.
-
User should see how good he/she rated compared to others that have taken the quiz, "You scored higher than 60% of all quizzers"
I created a multiple choice quiz that has options between A->D (4 choices to choose from)
Only one right answer per question.
There are 6 quesions the program loops through but the user only sees 3 questions at a time.
When the quiz is completed the user will see their results with the answer.
And if the user has scored higher than 60%, the user will see the printed "You scored higher than 60% of all quizzers"
The user will be asked if they would like to retry the quiz or if they would like to exit the application.
Last Edit: September 2022