From 79fb7651013064065436a9e88c46bd6a535d596d Mon Sep 17 00:00:00 2001 From: Andinus Date: Thu, 28 May 2020 14:39:26 +0530 Subject: Initialize variables properly --- myCovidCLI.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/myCovidCLI.go b/myCovidCLI.go index fbd06db..aa49097 100644 --- a/myCovidCLI.go +++ b/myCovidCLI.go @@ -17,9 +17,11 @@ import ( ) func main() { + var bodydata string + maxloops := 3 currentTime := time.Now() //get current time/date - bodydata := "" + for i := 0; i < maxloops; i++ { strcurrentdate := currentTime.Format("01-02-2006") //reformat for URL format @@ -47,15 +49,18 @@ func main() { //fmt.Println(bodydata) reader := csv.NewReader(strings.NewReader(bodydata)) - //zero out all variables - usconfirmed := 0 - usdeaths := 0 - usrecovered := 0 - region := "" - state := "" - confirmed := "" - deaths := "" - recovered := "" + // Initialize variables. + var ( + usconfirmed, + usdeaths, + usrecovered int + + region, + state, + confirmed, + deaths, + recovered string + ) data := [][]string{} for { -- cgit 1.4.1-2-gfad0