From 736f8b4daca53bee84ff157f570b2f5aeea96f35 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 20 Jan 2025 16:13:54 +0100 Subject: [PATCH] Don't use `defer` in a loop As the body of request isn't used, we can sloe it immediately. --- internal/integration/apprise/apprise.go | 2 +- internal/integration/discord/discord.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/integration/apprise/apprise.go b/internal/integration/apprise/apprise.go index 25ef5369..7b080006 100644 --- a/internal/integration/apprise/apprise.go +++ b/internal/integration/apprise/apprise.go @@ -69,7 +69,7 @@ func (c *Client) SendNotification(feed *model.Feed, entries model.Entries) error if err != nil { return fmt.Errorf("apprise: unable to send request: %v", err) } - defer response.Body.Close() + response.Body.Close() if response.StatusCode >= 400 { return fmt.Errorf("apprise: unable to send a notification: url=%s status=%d", apiEndpoint, response.StatusCode) diff --git a/internal/integration/discord/discord.go b/internal/integration/discord/discord.go index 2793e7bd..f6eb1a4a 100644 --- a/internal/integration/discord/discord.go +++ b/internal/integration/discord/discord.go @@ -82,7 +82,7 @@ func (c *Client) SendDiscordMsg(feed *model.Feed, entries model.Entries) error { if err != nil { return fmt.Errorf("discord: unable to send request: %v", err) } - defer response.Body.Close() + response.Body.Close() if response.StatusCode >= 400 { return fmt.Errorf("discord: unable to send a notification: url=%s status=%d", c.webhookURL, response.StatusCode)