package main import ( "fmt" "log" "log/slog" "os" cfg "website/internal/config" "github.com/ardanlabs/conf/v3" "github.com/pkg/errors" ) type Config struct { Production bool `conf:"default:false"` ListenAddress string `conf:"default:localhost"` Port uint16 `conf:"default:3000,short:p"` BaseURL cfg.URL `conf:"default:http://localhost:3000,short:b"` RedirectOtherHostnames bool `conf:"default:false"` } func main() { if os.Getenv("DEBUG") != "" { slog.SetLogLoggerLevel(slog.LevelDebug) } runtimeConfig := Config{} help, err := conf.Parse("", &runtimeConfig) if err != nil { if errors.Is(err, conf.ErrHelpWanted) { fmt.Println(help) os.Exit(1) } log.Panicf("parsing runtime configuration: %v", err) } startServer(&runtimeConfig) }