Explorar el Código

Merge pull request #244 from robbix1206/Example_Close_File

Close the file after read
Bruce hace 8 años
padre
commit
1acc7dc017
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  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
 		}