From 30ce2f00ab56a5de0d13e4a52e41f4f940071ec1 Mon Sep 17 00:00:00 2001 From: twoi Date: Sun, 18 Aug 2019 07:54:29 +0900 Subject: [PATCH] Add code comment to ease understanding As I'm [not the only one](https://github.com/VividCortex/go-database-sql-tutorial/issues/70) who stumbled upon this, let's just add a comment to the example code. No logging library I have worked with goes as far as terminating the program, so many go beginners may not understand this - although I think it does make sense. (Otherwise - what's the meaning of "fatal"?) --- retrieving.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/retrieving.md b/retrieving.md index 33cee55..c16c0b6 100644 --- a/retrieving.md +++ b/retrieving.md @@ -36,12 +36,14 @@ defer rows.Close() for rows.Next() { err := rows.Scan(&id, &name) if err != nil { + // log.Fatal will exit the program, preventing the deferred call to rows.Close() log.Fatal(err) } log.Println(id, name) } err = rows.Err() if err != nil { + // log.Fatal will exit the program, preventing the deferred call to rows.Close() log.Fatal(err) }