Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
chore: removed logs unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
renanbastos93 committed Apr 12, 2020
1 parent d38ac22 commit 015c26c
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"log"
"net/http"
"time"
Expand Down Expand Up @@ -54,10 +54,6 @@ func fetch(ctx context.Context, req *http.Request, ch chan LastValues) error {
log.Printf("fetchCOVID19Data: %v", err)
return err
}

bodyBytes, _ := ioutil.ReadAll(body.Body)
log.Println("WOOW: :: ", string(bodyBytes))

select {
case ch <- LastValues{r.Cases, r.Deaths, r.Recovered}:
case <-ctx.Done():
Expand All @@ -69,7 +65,6 @@ func fetch(ctx context.Context, req *http.Request, ch chan LastValues) error {
func fetchCOVID19Data(ctx context.Context, country string) <-chan LastValues {
ch := make(chan LastValues)
url := URL + country
log.Println("URL ::: ", url)
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
panic("internal error - misuse of NewRequestWithContext")
Expand All @@ -84,7 +79,6 @@ func routine(sleep time.Duration, country string) {
ctx, cancel := context.WithTimeout(context.Background(), TIMEOUT)
select {
case newVal := <-fetchCOVID19Data(ctx, country):
log.Println("newval :: ", newVal)
if cachedVal != newVal {
err := beeep.Alert("COVID-19 "+country, newVal.String(), IMG)
if err != nil {
Expand All @@ -96,7 +90,6 @@ func routine(sleep time.Duration, country string) {
log.Printf("rountine: %v", ctx.Err())
}
cancel()
log.Printf("sleeping for %s", sleep)
time.Sleep(sleep)
}
}
Expand All @@ -117,12 +110,11 @@ func getCountryByGeoIP() geoIP {
if err != nil {
log.Fatalf("Oops, we cannot get your location, please verify your network.")
}
log.Println("IP :: ", ip)
return ip
}

func main() {
// log.SetPrefix(os.Args[0] + ": ")
log.SetPrefix(os.Args[0] + ": ")
log.SetFlags(0)
var timer time.Duration
flag.DurationVar(&timer, "t", time.Hour, "interval between each api request")
Expand Down

0 comments on commit 015c26c

Please sign in to comment.