-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
44 lines (34 loc) · 873 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
package main
import (
"io/ioutil"
"log"
"os"
"gopkg.in/yaml.v2"
)
// Config main config file structure
type Config struct {
Port int `yaml:"port"`
ClientID string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"`
DbUsername string `yaml:"db_username"`
DbPassword string `yaml:"db_password"`
DbDatabase string `yaml:"db_database"`
SlackWebookURL string `yaml:"slack_webhook_url"`
DbHost string `yaml:"db_host"`
DbPort int `yaml:"db_port"`
}
var config Config
func loadConfig() {
if len(os.Args) < 2 {
log.Fatal("Missing required config parameter")
}
contents, err := ioutil.ReadFile(os.Args[1])
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(contents, &config)
if err != nil {
log.Fatalf("Error parsing config: %v", err)
}
log.Print("Config successfully loaded")
}