[BACKEND] Initialize Go backend structure and dependencies (#23)

This commit is contained in:
2026-02-15 22:50:06 +00:00
parent 7157877f0b
commit c75f976a2d
29 changed files with 1857 additions and 253 deletions

36
server/config/config.go Normal file
View File

@@ -0,0 +1,36 @@
package config
import (
"os"
"github.com/joho/godotenv"
)
// Config holds all application configuration.
type Config struct {
Port string
DatabaseURL string
JWTSecret string
Environment string
}
// Load reads configuration from environment variables.
// A .env file is loaded if present but not required.
func Load() *Config {
// Best-effort .env load (not required in production)
_ = godotenv.Load()
return &Config{
Port: getEnv("PORT", "8080"),
DatabaseURL: getEnv("DATABASE_URL", ""),
JWTSecret: getEnv("JWT_SECRET", "dev-secret-change-me"),
Environment: getEnv("ENVIRONMENT", "development"),
}
}
func getEnv(key, fallback string) string {
if v := os.Getenv(key); v != "" {
return v
}
return fallback
}