package config import ( "os" "strconv" "time" ) type Config struct { Server struct { Hostname string Port string Mode string // gin.Mode: debug, release, test } JWT struct { Secret string } Sync struct { Interval time.Duration } Admin struct { Email string Password string } SheetsDirectory string ConfigDirectory string } var AppConfig *Config func Load() { cfg := &Config{} // Server configuration cfg.Server.Hostname = getEnv("SERVER_HOSTNAME", "127.0.0.1") cfg.Server.Port = getEnv("SERVER_PORT", "8080") cfg.Server.Mode = getEnv("GIN_MODE", "debug") // JWT configuration cfg.JWT.Secret = getEnv("JWT_SECRET", "sheetless-default-jwt-secret-please-change") // Sync configuration syncMinutes := getEnvInt("SYNC_INTERVAL_MINUTES", 1) cfg.Sync.Interval = time.Duration(syncMinutes) * time.Minute // Admin configuration cfg.Admin.Email = getEnv("ADMIN_EMAIL", "admin@admin.com") cfg.Admin.Password = getEnv("ADMIN_PASSWORD", "sheetless") cfg.SheetsDirectory = getEnv("SHEETS_DIRECTORY", "./sheets_directory") cfg.ConfigDirectory = getEnv("CONFIG_DIRECTORY", "./config_directory") AppConfig = cfg } func getEnv(key, defaultValue string) string { if value := os.Getenv(key); value != "" { return value } return defaultValue } func getEnvInt(key string, defaultValue int) int { if value := os.Getenv(key); value != "" { if intValue, err := strconv.Atoi(value); err == nil { return intValue } } return defaultValue }