Skip to content

Conversation

@kannanenator
Copy link
Contributor

No description provided.

@damienstanton
Copy link

👋 Hi @kannanenator, I'll be reviewing your solution. I have a couple of minor suggestions, for which I'll comment in the PR in various places. Nice work!


filenamePtr := flag.String("filename", "problems.csv", "file containing the set of problems")
limitPtr := flag.Int("limit", 30, "quiz time limit")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a check based on the NArg func in the flag pkg to handle the case where I try to run the game with no flags.

fmt.Println("You got", numCorrect, "out of", numQs, "correct")
}

func handleError(err error){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, this kind of general error helper func is discouraged. While more verbose, we always prefer explicit handling at the call site. So instead of handleError, in each case where you get an error value, I would opt for using

log.Fatalf("could not open file: %v\n", err)

or

// if you want to print to stderr and trigger an unsuccessful exit, for example
fmt.Fprintf(os.Stderr, "could not read input string: %v\n", err)
os.Exit(1)

for idx, element := range rows {
q, a := element[0], element[1]
fmt.Print("Problem #", idx+1 ,": ", q, " = ")
input, _ := consoleReader.ReadString('\n')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping error values is a code smell, so unless your specific case calls for it, don't do it!

@joncalhoun joncalhoun added the in review PR/Issue is currently undergoing code review label Mar 7, 2018
@joncalhoun joncalhoun merged commit 92549a1 into gophercises:master Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in review PR/Issue is currently undergoing code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants