Skip to content

Commit

Permalink
handle file closure
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulsattar committed Jan 25, 2024
1 parent 779d4bd commit f927423
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion daemon.go
Expand Up @@ -13,7 +13,12 @@ func main() {
if err != nil {
log.Fatalln("Error initializing KV store", err)
}
defer kv.Close()
defer func(kv *KV) {
err := kv.Close()
if err != nil {
log.Fatalln("Failed to close")
}
}(kv)
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line := scanner.Text()
Expand Down

0 comments on commit f927423

Please sign in to comment.