From d9bf3b8ee89072cdec42af6d938a1bef0393c748 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Mon, 19 Dec 2022 17:38:26 -0500 Subject: [PATCH] fix: don't close HTTP body --- main.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index bb7e60c..e309949 100644 --- a/main.go +++ b/main.go @@ -83,12 +83,11 @@ func sourceFromArg(arg string) (*source, error) { if u.Scheme != "http" && u.Scheme != "https" { return nil, fmt.Errorf("%s is not a supported protocol", u.Scheme) } - - resp, err := http.Get(u.String()) + // consumer of the source is responsible for closing the ReadCloser. + resp, err := http.Get(u.String()) // nolint:bodyclose if err != nil { return nil, err } - defer resp.Body.Close() //nolint:errcheck if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("HTTP status %d", resp.StatusCode) }