feat: implement memogram

This commit is contained in:
Steven
2024-05-14 22:04:46 +08:00
parent 3ebf96c827
commit 1dca2ffce0
11 changed files with 274 additions and 0 deletions

25
config.go Normal file
View 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
}