package config import ( "log" "github.com/caarlos0/env/v11" ) type Config struct { Token string `env:"TOKEN"` UploadDir string `env:"UPLOAD_DIR" envDefault:"./uploads"` Port string `env:"PORT" envDefault:"8080"` MaxSizeUpload int64 `env:"MAX_SIZE_UPLOAD" envDefault:"104857600"` // 100 MB DBHost string `env:"DB_HOST" envDefault:"localhost"` DBPort string `env:"DB_PORT" envDefault:"5432"` DBUser string `env:"DB_USER" envDefault:"user"` DBPassword string `env:"DB_PASSWORD" envDefault:"password"` DBName string `env:"DB_NAME" envDefault:"app_db"` } func New() *Config { config := new(Config) if err := env.Parse(config); err != nil { log.Fatalf("ошибка при парсинге переменных %v", err) } return config } func (c *Config) GetUploadDir() string { return c.UploadDir }