write function to get env variables

This commit is contained in:
Chigozirim Igweamaka 2024-05-15 05:06:15 +01:00
parent e4d6a099eb
commit 9332b06003

View file

@ -2,6 +2,7 @@ package utils
import (
"math/rand"
"os"
"time"
)
@ -15,3 +16,14 @@ func GenerateUniqueID() uint32 {
func GenerateSongKey(songTitle, songArtist string) string {
return songTitle + "---" + songArtist
}
func GetEnv(key string, fallback ...string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
if len(fallback) > 0 {
return fallback[0]
}
return ""
}