Files
slideshowApp/env/enviroment.go
Adrian Zürcher e05c3a06ae
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 2m0s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m20s
Build Slideshow App / build (arm, 7, , linux) (push) Successful in 1m57s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m58s
some changes
2026-01-31 20:37:03 +01:00

44 lines
792 B
Go

package env
import (
"os"
"strings"
"github.com/joho/godotenv"
)
const (
Env EnvKey = "ENV"
PhotoDir EnvKey = "PHOTO_DIR"
Host EnvKey = "HOST"
Port EnvKey = "PORT"
IntervalDefault EnvKey = "INTERVAL_DEFAULT"
LogPath EnvKey = "LOG_PATH"
)
type EnvKey string
func Load(path string) error {
if path == "" {
path = ".env"
}
return godotenv.Load(path)
}
func (key EnvKey) GetValue() string {
port := os.Getenv(string(key))
if port == "" {
port = "8080"
}
return port
}
func (key EnvKey) SetValue(value string) {
os.Setenv(string(key), value)
}
func (key EnvKey) GetBoolValue() bool {
value := strings.ToLower(os.Getenv(string(key)))
return value == "true" || value == "1"
}