1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-21 04:52:38 +00:00

handle file error on closing (#2050)

* fix unhandled errors

* fix unhandled error in cache package test

* omit variable type

* omit variable type

* rename variable because collide with the imported package name

* handle file error on closing
This commit is contained in:
Amir Hossein 2022-08-26 18:16:45 +04:30 committed by GitHub
parent aef7ea53b3
commit b86f79eca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"log"
"net/url"
"os"
"os/exec"
@ -122,7 +123,12 @@ func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error) {
if err != nil {
return []string{""}, err
}
defer f.Close()
defer func(f *os.File) {
err := f.Close()
if err != nil {
log.Fatalln(err)
}
}(f)
var ret []string
@ -204,7 +210,12 @@ func ReadInts(filename string) ([]int64, error) {
if err != nil {
return []int64{}, err
}
defer f.Close()
defer func(f *os.File) {
err := f.Close()
if err != nil {
log.Fatalln(err)
}
}(f)
var ret []int64