Defer fd.Close() (fixes #37)

This commit is contained in:
kc1212 2016-03-21 01:07:51 +01:00
parent 2e44473ce4
commit ea61f8f597

View File

@ -95,6 +95,12 @@ func (s *statssrv) writeToFile(stats stats, secs float64) {
log.Println("stats file:", err)
return
}
defer func() {
err = fd.Close()
if err != nil {
log.Println("stats file:", err)
}
}()
bs, err := ioutil.ReadAll(fd)
if err != nil {
@ -127,10 +133,4 @@ func (s *statssrv) writeToFile(stats stats, secs float64) {
log.Println("stats file:", err)
return
}
err = fd.Close()
if err != nil {
log.Println("stats file:", err)
return
}
}