Files
astra-users/config/config.go
2023-06-30 19:01:21 +03:00

34 lines
492 B
Go

package config
import (
"os"
)
type ServerConfig struct {
Port string
ConnectionString string
}
type Config struct {
Server ServerConfig
}
func New() *Config {
return &Config{
Server: ServerConfig{
Port: getEnv("PORT", ""),
ConnectionString: getEnv("CONNECTION_STRING", "test.db"),
},
}
}
func getEnv(key string, defaultVal string) string {
if value, exists := os.LookupEnv(key); exists {
return value
}
return defaultVal
}
var Env = New()