From 1fe7542f4075ac80737fbb657c0047bf113bcd3d Mon Sep 17 00:00:00 2001 From: Mike Schwartz Date: Mon, 1 Jul 2019 18:22:10 -0700 Subject: [PATCH] Added deferred file close Removed unnecessary println --- gol/gc/ex1_quizgame/quiz.go | 2 +- gol/gc/ex1_quizgame/quiz_timed.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gol/gc/ex1_quizgame/quiz.go b/gol/gc/ex1_quizgame/quiz.go index b63051a..18f2797 100644 --- a/gol/gc/ex1_quizgame/quiz.go +++ b/gol/gc/ex1_quizgame/quiz.go @@ -24,6 +24,7 @@ func main() { if err != nil { log.Fatal(err) } + defer in.Close() r := csv.NewReader(in) ques, err := r.ReadAll() if err != nil { @@ -46,7 +47,6 @@ func main() { if err != nil { log.Fatal("Cannot interpret CSV value %v for question %v.", v[1], v[0]) } - fmt.Printf("user: %v, real: %v\n", user_answer, real_answer) if user_answer == real_answer { correct = correct + 1 } diff --git a/gol/gc/ex1_quizgame/quiz_timed.go b/gol/gc/ex1_quizgame/quiz_timed.go index c3daced..9337f92 100644 --- a/gol/gc/ex1_quizgame/quiz_timed.go +++ b/gol/gc/ex1_quizgame/quiz_timed.go @@ -32,6 +32,7 @@ func main() { if err != nil { log.Fatal(err) } + defer in.Close() r := csv.NewReader(in) ques, err := r.ReadAll() if err != nil {