summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@inventati.org>2020-03-15 13:35:59 +0530
committerAndinus <andinus@inventati.org>2020-03-15 13:35:59 +0530
commitd282ab6f0e7bcbb5dde2c5dd0ff0d2a59aea7fe5 (patch)
treef5b47e42f1bd04ab1884b61d5a7a9b143361972b
parentc1e489fbd281698b262d3114b08f875b1ff3b966 (diff)
downloadcetus-d282ab6f0e7bcbb5dde2c5dd0ff0d2a59aea7fe5.tar.gz
Clean up repeat variable declaration
-rw-r--r--cmd/cetus-nasa/cetus-nasa.go18
1 files changed, 5 insertions, 13 deletions
diff --git a/cmd/cetus-nasa/cetus-nasa.go b/cmd/cetus-nasa/cetus-nasa.go
index 801a89f..bb7ad6a 100644
--- a/cmd/cetus-nasa/cetus-nasa.go
+++ b/cmd/cetus-nasa/cetus-nasa.go
@@ -37,6 +37,9 @@ var (
 	dateHelp    string
 	dateDefault string
 	timeout     time.Duration
+
+	err     error
+	apodRes nasa.APOD
 )
 
 func main() {
@@ -54,12 +57,6 @@ func main() {
 		date = nasa.RandDate()
 	}
 
-	var (
-		picturePath string
-		apodRes     nasa.APOD
-		err         error
-	)
-
 	// get response from api
 	apodRes, err = getAPODRes()
 	if err != nil {
@@ -75,11 +72,10 @@ func main() {
 	if fetchOnly {
 		return
 	}
-	picturePath = apodRes.HDURL
 
 	// if media type is an image then set background
 	if apodRes.MediaType == "image" {
-		err = background.Set(picturePath)
+		err = background.Set(apodRes.HDURL)
 		if err != nil {
 			log.Fatal(err)
 		}
@@ -124,11 +120,7 @@ func printDetails(apodRes nasa.APOD) {
 }
 
 func getAPODRes() (nasa.APOD, error) {
-	var (
-		apodRes  nasa.APOD
-		err      error
-		apodInfo map[string]string
-	)
+	var apodInfo map[string]string
 	apodInfo = make(map[string]string)
 	apodInfo["api"] = api
 	apodInfo["apiKey"] = apiKey