23 lines
438 B
Go
23 lines
438 B
Go
|
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
|
||
|
}
|