40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
package initialize
|
|
|
|
import (
|
|
"github.com/caarlos0/env/v8"
|
|
"github.com/joho/godotenv"
|
|
"log"
|
|
)
|
|
|
|
type Config struct {
|
|
LoggerProdMode bool `env:"IS_PROD_LOG" envDefault:"false"`
|
|
IsProd bool `env:"IS_PROD" envDefault:"false"`
|
|
MinioEP string `env:"MINIO_EP" envDefault:"localhost:3002"`
|
|
MinioAK string `env:"MINIO_AK" envDefault:"minio"`
|
|
MinioSK string `env:"MINIO_SK" envDefault:"miniostorage"`
|
|
NumberPort string `env:"PORT" envDefault:"1490"`
|
|
HttpHost string `env:"HTTP_HOST" envDefault:"0.0.0.0"`
|
|
CrtFile string `env:"CRT" envDefault:"server.crt"`
|
|
KeyFile string `env:"KEY" envDefault:"server.key"`
|
|
PostgresCredentials string `env:"PG_CRED" envDefault:"host=localhost port=5432 user=squiz password=Redalert2 dbname=squiz sslmode=disable"`
|
|
RedisHost string `env:"REDIS_HOST"`
|
|
RedisPassword string `env:"REDIS_PASSWORD"`
|
|
RedisDB uint64 `env:"REDIS_DB"`
|
|
RedirectURL string `env:"REDIRECT_URL" envDefault:"https://squiz.pena.digital"`
|
|
PubKey string `env:"PUBLIC_KEY"`
|
|
PrivKey string `env:"PRIVATE_KEY"`
|
|
TrashLogHost string `env:"TRASH_LOG_HOST" envDefault:"localhost:7113"`
|
|
ModuleLogger string `env:"MODULE_LOGGER" envDefault:"answerer-local"`
|
|
}
|
|
|
|
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
|
|
}
|