about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-05-28 14:39:26 +0530
committerAndinus <andinus@nand.sh>2020-05-28 14:57:11 +0530
commit79fb7651013064065436a9e88c46bd6a535d596d (patch)
tree4cbe171185e39111edb83ac203bb7ccf1aee3c93
parenta2e5a922ae60fa4a3db7319bc3d01385966fcb34 (diff)
downloadmyCovidCLI-79fb7651013064065436a9e88c46bd6a535d596d.tar.gz
Initialize variables properly
-rw-r--r--myCovidCLI.go25
1 files 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 {