diff options
author | Maas Lalani <maas@lalani.dev> | 2022-12-19 17:38:26 -0500 |
---|---|---|
committer | Maas Lalani <maas@lalani.dev> | 2022-12-19 18:09:17 -0500 |
commit | d9bf3b8ee89072cdec42af6d938a1bef0393c748 (patch) | |
tree | 71e5dc5d5a048115088fdf3434052a21d0357250 | |
parent | 9f110c304b7e1d1773ab2b00a04cc5a2c13a774f (diff) |
fix: don't close HTTP body
-rw-r--r-- | main.go | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -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) } |