36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package initialize
|
|
|
|
import (
|
|
"gitea.pena/PenaSide/common/mongo"
|
|
"github.com/caarlos0/env/v8"
|
|
"github.com/joho/godotenv"
|
|
"log"
|
|
)
|
|
|
|
type Config struct {
|
|
LoggerDevMode bool `env:"BB_IS_PROD" envDefault:"false"`
|
|
MinioEndpoint string `env:"BB_MINIO_EP" envDefault:"localhost:9000"`
|
|
MinioAccessKey string `env:"BB_MINIO_AK" envDefault:"minioadmin"`
|
|
MinioSecretKey string `env:"BB_MINIO_SK" envDefault:"minioadmin"`
|
|
MinioToken string `env:"BB_MINIO_TOKEN" envDefault:""`
|
|
TgToken string `env:"TELEGRAM_TOKEN" envDefault:"7127966184:AAG1steOCH4wDvHRe9QcsXJPS4dWRyRYsqg"`
|
|
RedisHost string `env:"REDIS_HOST" envDefault:"localhost:6379"`
|
|
RedisPassword string `env:"REDIS_PASSWORD" envDefault:"admin"`
|
|
RedisDB int `env:"REDIS_DB" envDefault:"2"`
|
|
TgChatID uint64 `env:"TELEGRAM_CHAT_ID" envDefault:"1001344671794"`
|
|
HTTPHost string `env:"HTTP_HOST" envDefault:"localhost"`
|
|
HTTPPort string `env:"HTTP_PORT" envDefault:"3000"`
|
|
Database mongo.Configuration
|
|
}
|
|
|
|
func LoadConfig() (*Config, error) {
|
|
if err := godotenv.Load(); err != nil {
|
|
log.Print("No .env file found")
|
|
}
|
|
var config Config
|
|
if err := env.Parse(&config); err != nil {
|
|
return nil, err
|
|
}
|
|
return &config, nil
|
|
}
|