Files
mtusi2026lab2-implementation/internal/config/config.go
T

30 lines
432 B
Go

package config
import (
"net"
"os"
)
type Config struct {
Host string
Port string
Env string
}
func Load() Config {
return Config{
Host: getenv("APP_HOST", "0.0.0.0"),
Port: getenv("APP_PORT", "8080"),
Env: getenv("APP_ENV", "lab"),
}
}
func (c Config) Addr() string { return net.JoinHostPort(c.Host, c.Port) }
func getenv(key, def string) string {
if v := os.Getenv(key); v != "" {
return v
}
return def
}