30 lines
507 B
Go
30 lines
507 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
type Config struct {
|
|
Workers int
|
|
TgAPIKey string
|
|
TgChatID int64
|
|
VkAPIKey string
|
|
}
|
|
|
|
// MustLoad loads the config.
|
|
func MustLoad() *Config {
|
|
var Conf Config
|
|
var err error
|
|
Conf.Workers, err = strconv.Atoi(os.Getenv("Workers"))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
Conf.TgAPIKey = os.Getenv("TgAPIKey")
|
|
Conf.VkAPIKey = os.Getenv("VkAPIKey")
|
|
Conf.TgChatID, err = strconv.ParseInt(os.Getenv("TgChatID"), 10, 64)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return &Conf
|
|
}
|