MiniappGoService/internal/config/loadConfig.go

45 lines
789 B
Go

package config
import (
"github.com/caarlos0/env/v11"
)
var (
Config = new(config)
)
func Load() error {
// App configuration
app := new(App)
if err := env.Parse(app); err != nil {
return err
}
Config.App = app
// Bot configuration
bot := new(Bot)
if err := env.Parse(bot); err != nil {
return err
}
Config.Bot = bot
// PostgreSQL configuration
postgre := new(Postgre)
if err := env.Parse(postgre); err != nil {
return err
}
Config.Postgre = postgre
// Tokens configuration
tokens := new(Tokens)
if err := env.Parse(tokens); err != nil {
return err
}
Config.Tokens = tokens
// Integrations configuration
integrations := new(Integrations)
if err := env.Parse(integrations); err != nil {
return err
}
Config.Integrations = integrations
return nil
}