From b96512a039fb42542c708b186cd924665949d9e6 Mon Sep 17 00:00:00 2001 From: harisabdullah Date: Mon, 7 Aug 2023 13:24:33 +0500 Subject: [PATCH] Refactoring --- ipinfo/cmd_download.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ipinfo/cmd_download.go b/ipinfo/cmd_download.go index 5b37711d..fa1ffc21 100644 --- a/ipinfo/cmd_download.go +++ b/ipinfo/cmd_download.go @@ -146,6 +146,9 @@ func cmdDownload() error { url := fmt.Sprintf("%s%s.%s?token=%s", dbDownloadURL, dbName, format, token) err := downloadDb(url, fileName, format, fZip) + if err != nil { + return err + } // fetch checksums from API and check if they match. checksumUrl := fmt.Sprintf("%s%s.%s/checksums?token=%s", dbDownloadURL, dbName, format, token) @@ -165,10 +168,6 @@ func cmdDownload() error { return errors.New("checksums do not match. File might be corrupted") } - if err != nil { - return err - } - return nil } @@ -288,8 +287,8 @@ func fetchChecksums(url string) (*ChecksumResponse, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { return nil, err