Skip to content

Commit f179197

Browse files
committed
Fix linting errors - check error returns from Close()
- Wrap defer Close() calls to explicitly ignore errors - Satisfies errcheck linter - internal/client/client.go: resp.Body.Close() and out.Close() - internal/client/fetcher.go: resp.Body.Close()
1 parent d001112 commit f179197

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

internal/client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func downloadFile(url, destPath string) error {
360360
if err != nil {
361361
return err
362362
}
363-
defer resp.Body.Close()
363+
defer func() { _ = resp.Body.Close() }()
364364

365365
if resp.StatusCode != http.StatusOK {
366366
return fmt.Errorf("HTTP %d: %s", resp.StatusCode, resp.Status)
@@ -370,7 +370,7 @@ func downloadFile(url, destPath string) error {
370370
if err != nil {
371371
return err
372372
}
373-
defer out.Close()
373+
defer func() { _ = out.Close() }()
374374

375375
_, err = io.Copy(out, resp.Body)
376376
return err

internal/client/fetcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (f *FilesystemFetcher) DownloadFile(urlPath string, maxLength int64, _ time
6464
if err != nil {
6565
return nil, err
6666
}
67-
defer resp.Body.Close()
67+
defer func() { _ = resp.Body.Close() }()
6868

6969
if resp.StatusCode != http.StatusOK {
7070
return nil, &metadata.ErrDownloadHTTP{StatusCode: resp.StatusCode, URL: urlPath}

0 commit comments

Comments
 (0)