24 lines
513 B
Go
24 lines
513 B
Go
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
|
|
}
|
|
|
|
func New() *Config {
|
|
config := new(Config)
|
|
|
|
if err := env.Parse(config); err != nil {
|
|
log.Fatalf("ошибка при парсинге переменных %v", err)
|
|
}
|
|
|
|
return config
|
|
}
|