From 6001cdba8840c0ef420a9091a3666cf158743341 Mon Sep 17 00:00:00 2001 From: Alphyron Date: Sat, 11 Apr 2020 23:01:14 +0200 Subject: [PATCH] :wrench: Implement the TelegramConfig --- config/telegram.go | 14 ++++++++++++++ main.go | 7 +++++++ 2 files changed, 21 insertions(+) create mode 100644 config/telegram.go diff --git a/config/telegram.go b/config/telegram.go new file mode 100644 index 0000000..adc96f8 --- /dev/null +++ b/config/telegram.go @@ -0,0 +1,14 @@ +package config + +import "github.com/caarlos0/env" + +type TelegramConfig struct { + TelegramKey string `env:"TELEGRAM_KEY,required"` +} + +func (tc *TelegramConfig) LoadConfig() error { + if err := env.Parse(tc); err != nil { + return err + } + return nil +} diff --git a/main.go b/main.go index 43943ac..2ef8d2b 100644 --- a/main.go +++ b/main.go @@ -12,4 +12,11 @@ func main() { log.Println("Problem while loading database environment variables") log.Fatal(err) } + + err = config.TelegramConfig{}.LoadConfig() + + if err != nil { + log.Println("Problem while loading telegram environment variables") + log.Fatal(err) + } }