Browse Source

Close the file after read

Close the file when it has been full readed
robbix1206 8 years ago
parent
commit
95fdc0a971
1 changed files with 4 additions and 0 deletions
  1. 4 0
      examples/airhorn/main.go

+ 4 - 0
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
 		}