Skip to content

Commit 32771f1

Browse files
committed
catch error of file.Close()
It only panics, but that is most likely the best way dealing with it. I only tend to read file, so in case this errors, it should just die the hard way.
1 parent cc85dea commit 32771f1

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@ func main() {
137137
if err != nil {
138138
panic(err)
139139
}
140-
defer file.Close()
140+
defer func() {
141+
err = file.Close()
142+
if err != nil {
143+
panic(err)
144+
}
145+
}()
141146
csvreader := csv.NewReader(file)
142147
csvreader.Comma = '\t'
143148
lines, err := csvreader.ReadAll()

0 commit comments

Comments
 (0)