Skip to content

Commit ab8cd29

Browse files
committed
Fix: Error return value of resp.Body.Close is not checked
1 parent c5892dd commit ab8cd29

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,18 @@ func downloadTile(ctx context.Context, msgChan chan<- WSMessage, tile Tile, mapS
435435
}
436436

437437
if resp.StatusCode != http.StatusOK {
438-
resp.Body.Close()
438+
if err := resp.Body.Close(); err != nil {
439+
log.Printf("Could not close response body: %v", err)
440+
}
439441
log.Printf("Unexpected status code %d for tile %v. Retrying...", resp.StatusCode, tile)
440442
time.Sleep(time.Second * time.Duration(math.Pow(2, float64(attempt))))
441443
continue
442444
}
443445

444446
body, err := io.ReadAll(resp.Body)
445-
resp.Body.Close()
447+
if err := resp.Body.Close(); err != nil {
448+
log.Printf("Could not close response body: %v", err)
449+
}
446450
if err != nil {
447451
log.Printf("Error reading tile body for tile %v: %v. Retrying...", tile, err)
448452
time.Sleep(time.Second * time.Duration(math.Pow(2, float64(attempt))))

0 commit comments

Comments
 (0)