Skip to content

Commit c1842ae

Browse files
committed
Update main.go
1 parent 4ee564c commit c1842ae

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

cmd/deleteRedditHistory/main.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,38 @@
66

77
package main
88

9+
import (
10+
"fmt"
11+
"log"
12+
"os"
13+
)
14+
915
type envVars struct {
1016
appID string
1117
appSecret string
1218
userName string
1319
userPassword string
1420
}
1521

22+
func arrayHasNoEmptyStrings(envVars []string) bool {
23+
for _, value := range envVars {
24+
if value == "" {
25+
return false
26+
}
27+
}
28+
29+
return true
30+
}
31+
1632
func main() {
33+
e := envVars{
34+
os.Getenv("REDDIT_APP_ID"),
35+
os.Getenv("REDDIT_SECRET"),
36+
os.Getenv("REDDIT_USER_ID"),
37+
os.Getenv("REDDIT_USER_PASSWORD"),
38+
}
1739

40+
if !arrayHasNoEmptyStrings([]string{e.appID, e.appSecret, e.userName, e.userPassword}) {
41+
log.Fatal(fmt.Errorf("one of the last.fm environment variables is not present in your system"))
42+
}
1843
}

0 commit comments

Comments
 (0)