CUB-112: scaffold Go backend with Chi, pgx, health check
Some checks failed
Dev Build / build-test (pull_request) Failing after 1m39s

This commit is contained in:
dex-bot
2026-05-06 12:20:31 -04:00
parent 42285c5dac
commit 3fe0850711
9 changed files with 261 additions and 29 deletions

View File

@@ -0,0 +1,24 @@
package config
import (
"fmt"
"github.com/kelseyhightower/envconfig"
)
// Config holds all application configuration loaded from environment variables.
type Config struct {
DatabaseURL string `envconfig:"database_url" required:"true"`
Port string `envconfig:"port" default:"8080"`
CorsOrigin string `envconfig:"cors_origin" default:"*"`
LogLevel string `envconfig:"log_level" default:"info"`
}
// Load reads configuration from environment variables and returns a populated Config.
func Load() (*Config, error) {
var cfg Config
if err := envconfig.Process("", &cfg); err != nil {
return nil, fmt.Errorf("failed to load config: %w", err)
}
return &cfg, nil
}