Skip to content

Commit

Permalink
Return close error
Browse files Browse the repository at this point in the history
  • Loading branch information
ngrash committed Dec 21, 2023
1 parent 339980d commit e339a7e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions geozip.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func downloadURL(cc string) string {
return fmt.Sprintf("https://download.geonames.org/export/zip/%s.zip", cc)
}

func download(url, etag string) ([]byte, bool, string, error) {
func download(url, etag string) (_ []byte, _ bool, _ string, err error) {
req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
return nil, false, "", err
Expand All @@ -122,7 +122,9 @@ func download(url, etag string) ([]byte, bool, string, error) {
return nil, false, "", err
}
defer func(Body io.ReadCloser) {
err = Body.Close()
if closeErr := Body.Close(); closeErr != nil {
err = closeErr
}
}(resp.Body)

if resp.StatusCode == http.StatusNotModified {
Expand Down

0 comments on commit e339a7e

Please sign in to comment.