-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
37 lines (31 loc) · 825 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"os"
"github.com/fatih/color"
"github.com/joho/godotenv"
)
// Config
var passwordFile = "password.txt"
var printerIpFile = "printer_ip_list.txt"
var errorFile = "errors.txt"
var appEnv = func() string {
value := GetEnvVariable("APP_ENV")
if value == "" { // Default APP_ENV=prod
return "prod"
}
return value
}()
// Colors
var successColor = color.New(color.FgGreen).SprintFunc()
var infoColor = color.New(color.FgBlue).SprintFunc()
var errorColor = color.New(color.FgRed).SprintFunc()
// Use godot package to load/read the .env file and return the value of the key.
func GetEnvVariable(key string) string {
// load .env file
err := godotenv.Load(".env")
if err != nil {
// We are not required to have a .env file
//log.Fatalf("Error loading .env file")
}
return os.Getenv(key)
}