mirror of
https://github.com/kemko/memes-telegram-integration.git
synced 2026-01-01 15:55:41 +03:00
feat: implement memogram
This commit is contained in:
25
config.go
Normal file
25
config.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package memogram
|
||||
|
||||
import (
|
||||
"github.com/caarlos0/env"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ServerAddr string `env:"SERVER_ADDR,required"`
|
||||
BotToken string `env:"BOT_TOKEN,required"`
|
||||
}
|
||||
|
||||
func getConfigFromEnv() (*Config, error) {
|
||||
err := godotenv.Load(".env")
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
config := Config{}
|
||||
if err := env.Parse(&config); err != nil {
|
||||
return nil, errors.Wrap(err, "invalid configuration")
|
||||
}
|
||||
return &config, nil
|
||||
}
|
||||
Reference in New Issue
Block a user