Преглед на файлове

Close the file after read

Close the file when it has been full readed
robbix1206 преди 8 години
родител
ревизия
95fdc0a971
променени са 1 файла, в които са добавени 4 реда и са изтрити 0 реда
  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
 		}