From 4fc91fae8f177af99a8f9484ba1e0d54ff472888 Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 15 Apr 2020 15:18:42 -0400 Subject: [PATCH] make lib --- weatherbot/{main.go => bot.go} | 17 ----------------- 1 file changed, 17 deletions(-) rename weatherbot/{main.go => bot.go} (58%) diff --git a/weatherbot/main.go b/weatherbot/bot.go similarity index 58% rename from weatherbot/main.go rename to weatherbot/bot.go index b39b70a..c3c6c45 100644 --- a/weatherbot/main.go +++ b/weatherbot/bot.go @@ -12,23 +12,6 @@ var apiKey = "7501365e9803ca244bf100fb41084538" var lat = "39.004608" var long = "-76.875671" -func main() { - oneCallUrl := fmt.Sprintf("https://api.openweathermap.org/data/2.5/onecall?lat=%v&lon=%v&units=imperial&appid=%v", lat, long, apiKey) - response, err := http.Get(oneCallUrl) - - if err != nil { - log.Fatalf("The HTTP request failed with error %s\n", err) - } - data, _ := ioutil.ReadAll(response.Body) - - var report OneCallReport - err = json.Unmarshal(data, &report) - if err != nil { - log.Fatal(err) - } - fmt.Println(TodayToReport(report.Daily[0])) -} - func GetDailyReport() string { oneCallUrl := fmt.Sprintf("https://api.openweathermap.org/data/2.5/onecall?lat=%v&lon=%v&units=imperial&appid=%v", lat, long, apiKey) response, err := http.Get(oneCallUrl)