pkg/services/alerting/notifiers/telegram.go: check error before close.

See,
$ gometalinter --vendor --deadline 6m --disable-all --enable=megacheck ./...
pkg/services/alerting/notifiers/telegram.go:130:2⚠️ should check returned error before deferring imageFile.Close() (SA5001) (megacheck)
This commit is contained in:
Mario Trangoni 2018-10-11 19:51:54 +02:00
parent 18e127db2a
commit 9c44c75936

View File

@ -127,7 +127,13 @@ func (this *TelegramNotifier) buildMessageInlineImage(evalContext *alerting.Eval
var err error
imageFile, err = os.Open(evalContext.ImageOnDiskPath)
defer imageFile.Close()
defer func() {
err := imageFile.Close()
if err != nil {
log.Error2("Could not close Telegram inline image.", "err", err)
}
}()
if err != nil {
return nil, err
}