Documentation
¶
Overview ¶
Package deferred provides helpers to close `io.Closer“. This helpers can be used as one-liner with defer keyword to call `Close` method and check error if occurs.
example: ```go
...
resp, err := http.Get("http://example.com/")
if err != nil {
// Handle error
}
defer deferred.CloseOrLog(resp.Body, logger)
...
```
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseOrLog ¶
CloseOrLog tries to close `cl`. If error returned, log it. Supports loggers that have `Errorf` method. Like :
zap logrus apex/log etc...
func CloseOrLogCtx ¶
CloseOrLogCtx tries to close `cl`. If error returned, log it. Supports loggers that have `Errorf` method. Like :
zap logrus apex/log etc...
func CloseOrLogStd ¶
CloseOrLogStd tries to close `cl`. If error returned, log it with standard `log`.
func CloseOrLogStdCtx ¶
CloseOrLogCtx tries to close `cl`. If error returned, log it with standard `log`.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.