/
settings.go
47 lines (40 loc) · 1 KB
/
settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package config
import (
"github.com/BurntSushi/toml"
"log"
)
type Settings struct {
Main MainSection `toml:"main"`
Excel ExcelSection `toml:"excel"`
Smtp SmtpSection `toml:"smtp"`
Debug DebugSection `toml:"debug"`
}
type MainSection struct {
Template string `toml:"template"`
SenderEmail string `toml:"sender-email"`
SenderName string `toml:"sender-name"`
SendEmail bool `toml:"send-email"`
}
type SmtpSection struct {
Host string `toml:"host"`
Port int `toml:"port"`
Auth bool `toml:"auth"`
User string `toml:"user"`
Password string `toml:"password"`
}
type ExcelSection struct {
File string `toml:"file"`
EmailColumn string `toml:"email-column"`
NameColumn string `toml:"name-column"`
}
type DebugSection struct {
SendTo string `toml:"send-to"`
Debugging bool `toml:"debugging"`
}
func New(configFile string) Settings {
settings := Settings{}
if _, err := toml.DecodeFile(configFile, &settings); err != nil {
log.Fatal(err)
}
return settings
}