diff --git a/ch5/fetch/main.go b/ch5/fetch/main.go index c83819547..fe2820a2b 100644 --- a/ch5/fetch/main.go +++ b/ch5/fetch/main.go @@ -34,7 +34,7 @@ func fetch(url string) (filename string, n int64, err error) { } n, err = io.Copy(f, resp.Body) // Close file, but prefer error from Copy, if any. - if closeErr := f.Close(); err == nil { + if closeErr := f.Close(); closeErr != nil && err == nil { err = closeErr } return local, n, err