1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-18 01:50:50 +00:00
strimertul/utils/deferlogger.go
2023-04-23 02:26:46 +02:00

17 lines
324 B
Go

package utils
import (
"io"
"reflect"
"runtime/debug"
"go.uber.org/zap"
)
func Close(res io.Closer, logger *zap.Logger) {
err := res.Close()
if err != nil {
logger.Error("Could not close resource", zap.String("name", reflect.TypeOf(res).String()), zap.Error(err), zap.String("stack", string(debug.Stack())))
}
}