From 245cc313b3072b55aa949be4e7e4dc1b1c3d1028 Mon Sep 17 00:00:00 2001 From: ibnaleem Date: Wed, 25 Dec 2024 18:29:16 +0000 Subject: [PATCH] fixes #14 by rewriting functions to handle json data --- gosearch.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gosearch.go b/gosearch.go index dbc425c..a1c9649 100644 --- a/gosearch.go +++ b/gosearch.go @@ -80,12 +80,12 @@ func UnmarshalJSON() (Data, error) { // 2. Read the latest data.json file from the repository // Bonus: it does not download the data.json file, it just reads it from the repository. - // err := os.Remove("data.json") - // if err != nil && !os.IsNotExist(err) { - // return Data{}, fmt.Errorf("error deleting old data.json: %w", err) - // } + err := os.Remove("data.json") + if err != nil && !os.IsNotExist(err) { + return Data{}, fmt.Errorf("error deleting old data.json: %w", err) + } - url := "https://raw.githubusercontent.com/ibnaleem/gosearch/refs/heads/yaml-error/data.json" + url := "https://raw.githubusercontent.com/ibnaleem/gosearch/refs/heads/main/data.json" resp, err := http.Get(url) if err != nil { return Data{}, fmt.Errorf("error downloading data.json: %w", err) @@ -554,4 +554,4 @@ func main() { fmt.Println(":: Total time taken : ", elapsed) os.Exit(0) -} \ No newline at end of file +}