Chore: prefix for environment variables

pull/1475/head
AH-dark 3 years ago
parent c4e252fa99
commit bba4e7044a
No known key found for this signature in database
GPG Key ID: 73D3D212EB75AB80

@ -6,9 +6,11 @@ import (
"strings" "strings"
) )
const prefix = "CD_"
// EnvStr returns the value of the environment variable named by the key. // EnvStr returns the value of the environment variable named by the key.
func EnvStr(key, defaultValue string) string { func EnvStr(key, defaultValue string) string {
if value, exist := os.LookupEnv(key); exist { if value, exist := os.LookupEnv(prefix + key); exist {
return value return value
} }
@ -17,7 +19,7 @@ func EnvStr(key, defaultValue string) string {
// EnvInt returns the value of the environment variable named by the key. // EnvInt returns the value of the environment variable named by the key.
func EnvInt(key string, defaultValue int) int { func EnvInt(key string, defaultValue int) int {
if value, exist := os.LookupEnv(key); exist { if value, exist := os.LookupEnv(prefix + key); exist {
number, err := strconv.Atoi(value) number, err := strconv.Atoi(value)
if err != nil { if err != nil {
// I think that we should log this error // I think that we should log this error
@ -32,7 +34,7 @@ func EnvInt(key string, defaultValue int) int {
// EnvArr returns the value of the environment variable named by the key. // EnvArr returns the value of the environment variable named by the key.
func EnvArr(key string, defaultValue []string) []string { func EnvArr(key string, defaultValue []string) []string {
if value, exist := os.LookupEnv(key); exist { if value, exist := os.LookupEnv(prefix + key); exist {
return strings.Split(value, ",") return strings.Split(value, ",")
} }

Loading…
Cancel
Save