From 95fdc0a97182ee8f2466401d88346310f3ff3ed9 Mon Sep 17 00:00:00 2001 From: robbix1206 Date: Wed, 31 Aug 2016 16:40:45 +0200 Subject: [PATCH] Close the file after read Close the file when it has been full readed --- examples/airhorn/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/airhorn/main.go b/examples/airhorn/main.go index cc61301..160ca85 100644 --- a/examples/airhorn/main.go +++ b/examples/airhorn/main.go @@ -131,6 +131,10 @@ func loadSound() error { // If this is the end of the file, just return. if err == io.EOF || err == io.ErrUnexpectedEOF { + file.Close() + if err != nil { + return err + } return nil }