Procházet zdrojové kódy

Close the file after read

Close the file when it has been full readed
robbix1206 před 8 roky
rodič
revize
95fdc0a971
1 změnil soubory, kde provedl 4 přidání a 0 odebrání
  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
 		}