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

28 lines
647 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"`
Repo string `env:"REPO"`
UploadDir string `env:"UPLOAD_DIR" envDefault:"./uploads"`
TaskDir string `env:"TASK_DIR" envDefault:"./tasks"`
SymLink string `env:"SYM_LINK"`
Port string `env:"PORT" envDefault:"8080"`
MaxSizeUpload int64 `env:"MAX_SIZE_UPLOAD" envDefault:"104857600"` //100 MB
}
func New() *Config {
config := new(Config)
if err := env.Parse(config); err != nil {
log.Fatalf("ошибка при парсинге переменных %v", err)
}
return config
}