Merge pull request #1510 from CallanTaylor/close-file

Close file
This commit is contained in:
fatedier 2019-11-12 14:02:49 +08:00 committed by GitHub
commit 21a126e4e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,6 +55,7 @@ func ReadFile(file string) (content string, err error) {
if err != nil { if err != nil {
return content, err return content, err
} }
defer file.Close()
buf, err := ioutil.ReadAll(file) buf, err := ioutil.ReadAll(file)
if err != nil { if err != nil {
return content, err return content, err
@ -65,6 +66,7 @@ func ReadFile(file string) (content string, err error) {
if err != nil { if err != nil {
return content, err return content, err
} }
defer file.Close()
buf, err := ioutil.ReadAll(file) buf, err := ioutil.ReadAll(file)
if err != nil { if err != nil {
return content, err return content, err