From ab8cd292db4a091012cfd2ad11d5c27f07969376 Mon Sep 17 00:00:00 2001 From: Nils Date: Wed, 27 Aug 2025 11:00:37 +0200 Subject: [PATCH] Fix: Error return value of `resp.Body.Close` is not checked --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index b820211..e4e95e8 100644 --- a/main.go +++ b/main.go @@ -435,14 +435,18 @@ func downloadTile(ctx context.Context, msgChan chan<- WSMessage, tile Tile, mapS } if resp.StatusCode != http.StatusOK { - resp.Body.Close() + if err := resp.Body.Close(); err != nil { + log.Printf("Could not close response body: %v", err) + } log.Printf("Unexpected status code %d for tile %v. Retrying...", resp.StatusCode, tile) time.Sleep(time.Second * time.Duration(math.Pow(2, float64(attempt)))) continue } body, err := io.ReadAll(resp.Body) - resp.Body.Close() + if err := resp.Body.Close(); err != nil { + log.Printf("Could not close response body: %v", err) + } if err != nil { log.Printf("Error reading tile body for tile %v: %v. Retrying...", tile, err) time.Sleep(time.Second * time.Duration(math.Pow(2, float64(attempt))))