Skip to content

Commit

Permalink
fixes #14 by rewriting functions to handle json data
Browse files Browse the repository at this point in the history
  • Loading branch information
ibnaleem committed Dec 25, 2024
1 parent 935cff1 commit 245cc31
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gosearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -554,4 +554,4 @@ func main() {
fmt.Println(":: Total time taken : ", elapsed)

os.Exit(0)
}
}

0 comments on commit 245cc31

Please sign in to comment.