Skip to content

Commit 30ce2f0

Browse files
authored
Add code comment to ease understanding
As I'm [not the only one](VividCortex#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"?)
1 parent ccce84f commit 30ce2f0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: retrieving.md

+2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ defer rows.Close()
3636
for rows.Next() {
3737
err := rows.Scan(&id, &name)
3838
if err != nil {
39+
// log.Fatal will exit the program, preventing the deferred call to rows.Close()
3940
log.Fatal(err)
4041
}
4142
log.Println(id, name)
4243
}
4344
err = rows.Err()
4445
if err != nil {
46+
// log.Fatal will exit the program, preventing the deferred call to rows.Close()
4547
log.Fatal(err)
4648
}
4749
</pre>

0 commit comments

Comments
 (0)