Skip to content

Commit e339a7e

Browse files
committed
Return close error
1 parent 339980d commit e339a7e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

geozip.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func downloadURL(cc string) string {
111111
return fmt.Sprintf("https://download.geonames.org/export/zip/%s.zip", cc)
112112
}
113113

114-
func download(url, etag string) ([]byte, bool, string, error) {
114+
func download(url, etag string) (_ []byte, _ bool, _ string, err error) {
115115
req, err := http.NewRequest(http.MethodGet, url, nil)
116116
if err != nil {
117117
return nil, false, "", err
@@ -122,7 +122,9 @@ func download(url, etag string) ([]byte, bool, string, error) {
122122
return nil, false, "", err
123123
}
124124
defer func(Body io.ReadCloser) {
125-
err = Body.Close()
125+
if closeErr := Body.Close(); closeErr != nil {
126+
err = closeErr
127+
}
126128
}(resp.Body)
127129

128130
if resp.StatusCode == http.StatusNotModified {

0 commit comments

Comments
 (0)