🔧 Implement the TelegramConfig
This commit is contained in:
parent
91843e34e4
commit
6001cdba88
14
config/telegram.go
Normal file
14
config/telegram.go
Normal file
@ -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
|
||||||
|
}
|
7
main.go
7
main.go
@ -12,4 +12,11 @@ func main() {
|
|||||||
log.Println("Problem while loading database environment variables")
|
log.Println("Problem while loading database environment variables")
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = config.TelegramConfig{}.LoadConfig()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Problem while loading telegram environment variables")
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user