123456789101112131415161718192021222324252627282930313233343536 |
- package config
- import (
- "log"
- "os"
- "github.com/joho/godotenv"
- )
- type config struct {
- Redis string
- Token string
- Channel string
- AdminChats []int64
- }
- var conf *config = nil
- func Get() *config {
- if nil == conf {
- err := godotenv.Load(".env")
- if err != nil {
- log.Printf("[config]: .env parse failed")
- }
- var configInstance config
- configInstance.Redis = os.Getenv("REDIS")
- configInstance.Token = os.Getenv("BOT_TOKEN")
- configInstance.Channel = os.Getenv("CHANNEL")
- configInstance.AdminChats = append(configInstance.AdminChats, 388107612)
- conf = &configInstance
- }
- return conf
- }
|