瀏覽代碼

Merge pull request #244 from robbix1206/Example_Close_File

Close the file after read
Bruce 8 年之前
父節點
當前提交
1acc7dc017
共有 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
 		}