Milen/config.go

26 lines
340 B
Go

2020-05-11 05:30:07 +07:00
package main
import (
"io/ioutil"
"github.com/BurntSushi/toml"
)
type config struct {
Token string
ReportTarget string
}
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
}