fix: close Body correctly

This commit is contained in:
Oleh Astappiev 2024-12-08 20:55:06 +01:00
parent 02580cce20
commit 254effa8e5
No known key found for this signature in database
GPG key ID: 37D7AC22589E9632
2 changed files with 6 additions and 3 deletions

View file

@ -47,6 +47,9 @@ func sendRequest(ctx context.Context, url string, body interface{}, headers http
status := resp.StatusCode
if status < 200 || status >= 300 {
defer func() {
_ = resp.Body.Close()
}()
return nil, fmt.Errorf("request failed with status %d", status)
}