From 7f0dd9c504756f558df1a3d8930d0745497a3912 Mon Sep 17 00:00:00 2001 From: Lorenzo Landolfi Date: Mon, 6 Jul 2015 21:25:18 +0200 Subject: [PATCH] little fix that sometimes causes crash --- methods.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/methods.go b/methods.go index 7f822a2..dbd19d8 100644 --- a/methods.go +++ b/methods.go @@ -132,9 +132,10 @@ type WebhookConfig struct { // All requests are POSTs because Telegram doesn't care, and it's easier. func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (APIResponse, error) { resp, err := http.PostForm("https://api.telegram.org/bot"+bot.Token+"/"+endpoint, params) - defer resp.Body.Close() if err != nil { return APIResponse{}, err + } else { + defer resp.Body.Close() } bytes, err := ioutil.ReadAll(resp.Body)