aides-repo-api/internal/config/config.go

31 lines
794 B
Go
Raw Normal View History

2024-12-12 07:54:50 +00:00
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"`
2024-12-12 07:54:50 +00:00
}
func New() *Config {
config := new(Config)
if err := env.Parse(config); err != nil {
log.Fatalf("ошибка при парсинге переменных %v", err)
}
return config
}