mirror of
https://github.com/Luzifer/automail.git
synced 2024-12-20 04:51:20 +00:00
24 lines
419 B
Go
24 lines
419 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/pkg/errors"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type config struct {
|
|
Handlers []mailHandler `yaml:"handlers"`
|
|
}
|
|
|
|
func loadConfig() (*config, error) {
|
|
var out = &config{}
|
|
|
|
f, err := os.Open(cfg.Config)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "Unable to open config file")
|
|
}
|
|
defer f.Close()
|
|
|
|
return out, errors.Wrap(yaml.NewDecoder(f).Decode(out), "Unable to decode config")
|
|
}
|