From a0916d8294c540a0867753bf2543839025abbda2 Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 26 Oct 2021 13:33:58 -0400 Subject: [PATCH] defer properly --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 71700a0..6094eb3 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,6 @@ type Patch struct { func LoadPatches(pl *PatchList, url string) { res, err := http.Get(url) - defer res.Body.Close() if err != nil { log.Printf("Got %v, retrying in 5s", err) time.Sleep(5 * time.Second) @@ -35,6 +34,8 @@ func LoadPatches(pl *PatchList, url string) { return } } + defer res.Body.Close() + body, readErr := ioutil.ReadAll(res.Body) if readErr != nil { log.Fatal(readErr)