-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
48 lines (41 loc) · 984 Bytes
/
config.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
48
package teamvite
import (
"encoding/json"
"log"
"os"
)
var CONFIG Config
var DefaultConfigPath = "config.json"
type Config struct {
Servername string `json:"servername"` // teamvite.com, teamvitedev.com
SMTP SMTPConfig
SMS SMSConfig
}
type SMTPConfig struct {
Hostname string `json:"hostname"`
Port int `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
}
type SMSConfig struct {
Sid string `json:"sid"`
Token string `json:"token"`
API string `json:"api"`
From string `json:"from"` // From phone number
}
func LoadConfig(filename string) (c Config, err error) {
f, err := os.ReadFile(filename)
if err != nil {
return
// log.Fatalln("[FATAL]: config file not found: ", configFile)
}
err = json.Unmarshal(f, &c)
return
}
func DefaultConfig() (c Config) {
c, err := LoadConfig(DefaultConfigPath)
if err != nil {
log.Fatalln("[FAIL]: Unable to load config ", DefaultConfigPath, err)
}
return c
}