heating-monitor/internal/config/config.go
2024-11-28 13:52:58 +01:00

46 lines
1.1 KiB
Go

package config
import (
"log"
"os"
"github.com/joho/godotenv"
)
type Config struct {
TelegramToken string
ChatID string
DBPath string
WebPort string
ProgramAuthor string
ProgramLink string
ProgramAvatar string
ProgramName string
ProgramVersion string
ProgramYear string
ProgramTechnologies string
}
func LoadConfig() (*Config, error) {
err := godotenv.Load()
if err != nil {
log.Println("No se pudo cargar el archivo .env, usando variables de entorno")
}
cfg := &Config{
TelegramToken: os.Getenv("TELEGRAM_TOKEN"),
ChatID: os.Getenv("CHAT_ID"),
DBPath: os.Getenv("DB_PATH"),
WebPort: os.Getenv("WEB_PORT"),
ProgramAuthor: os.Getenv("PROGRAM_AUTHOR"),
ProgramLink: os.Getenv("PROGRAM_LINK"),
ProgramAvatar: os.Getenv("PROGRAM_AVATAR"),
ProgramName: os.Getenv("PROGRAM_NAME"),
ProgramVersion: os.Getenv("PROGRAM_VERSION"),
ProgramYear: os.Getenv("PROGRAM_YEAR"),
ProgramTechnologies: os.Getenv("PROGRAM_TECHNOLOGIES"),
}
return cfg, nil
}