package env import ( "os" "strconv" "strings" "github.com/joho/godotenv" ) type EnvKey string const ( Env EnvKey = "ENV" GinMode EnvKey = "GIN_MODE" Debug EnvKey = "DEBUG" PrivKey EnvKey = "PRIVKEY" Fullchain EnvKey = "FULLCHAIN" Https EnvKey = "HTTPS" HostUrl EnvKey = "HOST_URL" HostPort EnvKey = "HOST_PORT" WorkingDir EnvKey = "WORKING_DIR" Spa EnvKey = "SPA" AccessSecret EnvKey = "ACCESS_SECRET" RefreshSecret EnvKey = "REFRESH_SECRET" Organization EnvKey = "ORGANIZATION" DOMAIN EnvKey = "DOMAIN" AllowOrigin EnvKey = "ALLOWORIGIN" TimeZone EnvKey = "TMEZONE" ) const ( EnvDevelopment = "development" EnvProduction = "Prodction" ) func (key EnvKey) GetValue() string { return os.Getenv(string(key)) } func (key EnvKey) GetBoolValue() bool { return strings.ToLower(os.Getenv(string(key))) == "true" } func (key EnvKey) GetUIntValue() uint { value, err := strconv.ParseUint(os.Getenv(string(key)), 10, 32) if err != nil { return 0 } return uint(value) } func Load(file string) error { return godotenv.Load(file) } func InDevelopmentMode() bool { return Env.GetValue() == EnvDevelopment } func InDebugMode() bool { return strings.ToLower(Debug.GetValue()) == "true" }