TelegramRepostBot/config/config.go

23 lines
438 B
Go
Raw Normal View History

2023-08-01 13:09:19 +00:00
package config
import (
"fmt"
"github.com/caarlos0/env"
)
type Config struct {
ApiToken string `env:"API_TOKEN"`
GroupID int64 `env:"GROUP_ID"`
ChannelID int64 `env:"CHANNEL_ID"`
LogLevel string `env:"LOG_LVL" envDefault:"info"`
}
func LoadConfig() (*Config, error) {
config := &Config{}
if err := env.Parse(config); err != nil {
return nil, fmt.Errorf("error parsing configuration: %w", err)
}
return config, nil
}