瀏覽代碼

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
 		}