From 7603d6636302a0622de1e235c5c540a6da4c9dec Mon Sep 17 00:00:00 2001 From: parmaster Date: Tue, 9 Jul 2024 21:42:26 +0300 Subject: [PATCH] checking err!=nil in defer --- client/client.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/client/client.go b/client/client.go index 044ceaa..2fbea13 100644 --- a/client/client.go +++ b/client/client.go @@ -62,8 +62,9 @@ func (z *ZoomClient) Authorize() error { return err } defer func() { - err := resp.Body.Close() - log.Printf("[ERROR] failed to close response: %v", err) + if err := resp.Body.Close(); err != nil { + log.Printf("[ERROR] failed to close response: %v", err) + } }() if resp.StatusCode != http.StatusOK { @@ -143,8 +144,9 @@ func (z *ZoomClient) GetIntervalMeetings(ctx context.Context, from, to time.Time return nil, err } defer func() { - err := resp.Body.Close() - log.Printf("[ERROR] failed to close response: %v", err) + if err := resp.Body.Close(); err != nil { + log.Printf("[ERROR] failed to close response: %v", err) + } }() if resp.StatusCode != http.StatusOK { @@ -259,8 +261,9 @@ func (z *ZoomClient) GetCloudStorageReport(from, to string) (*model.CloudRecordi return nil, err } defer func() { - err := resp.Body.Close() - log.Printf("[ERROR] failed to close response: %v", err) + if err := resp.Body.Close(); err != nil { + log.Printf("[ERROR] failed to close response: %v", err) + } }() if resp.StatusCode != http.StatusOK { @@ -320,8 +323,9 @@ func (z *ZoomClient) DeleteMeetingRecordings(meetingId string, delete bool) erro return err } defer func() { - err := resp.Body.Close() - log.Printf("[ERROR] failed to close response: %v", err) + if err := resp.Body.Close(); err != nil { + log.Printf("[ERROR] failed to close response: %v", err) + } }() // 404 StatusNotFound happens when meeting is already deleted or trashed, so ignore the error