Milen/config.go

29 lines
514 B
Go

2020-05-11 05:30:07 +07:00
package main
import (
"io/ioutil"
"github.com/BurntSushi/toml"
)
type config struct {
Token string
2020-05-30 12:51:04 +07:00
ReportTarget string `toml:"report_target"`
2020-05-30 14:50:26 +07:00
LevelRoles []string `toml:"level_roles"`
2020-05-30 12:51:04 +07:00
MacroReplace map[string]string `toml:"macro_replace"`
Macro map[string]string
2020-05-11 05:30:07 +07:00
}
func LoadConfig() config {
bytes, err := ioutil.ReadFile("config.toml")
if err != nil {
panic(err)
}
var cfg config
err = toml.Unmarshal(bytes, &cfg)
if err != nil {
panic(err)
}
return cfg
}