Skip to content

Commit 8782831

Browse files
committed
chore: Fixed gosec issue
1 parent 28fa1b8 commit 8782831

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

common/downloader/file_downloader.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ func (d *FileDownloader) DownloadTo(url string, outputName string) (dest string,
5858
if err != nil {
5959
return "", 0, err
6060
}
61-
defer resp.Body.Close()
61+
62+
defer func() error {
63+
if err := resp.Body.Close(); err != nil {
64+
return err
65+
}
66+
return nil
67+
}()
6268

6369
if resp.StatusCode != 200 {
6470
return "", 0, fmt.Errorf("Unexpected response code %d", resp.StatusCode)

common/rest/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ func (c *Client) DoWithContext(ctx context.Context, r *Request, respV interface{
6767
if err != nil {
6868
return resp, err
6969
}
70-
defer resp.Body.Close()
70+
defer func() error {
71+
if err := resp.Body.Close(); err != nil {
72+
return err
73+
}
74+
return nil
75+
}()
7176

7277
if resp.StatusCode < 200 || resp.StatusCode > 299 {
7378
raw, err := ioutil.ReadAll(resp.Body)

0 commit comments

Comments
 (0)