-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.go
40 lines (33 loc) · 796 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
package main
import (
"encoding/json"
"io/ioutil"
"log"
"os"
)
type ServerConfig struct {
Hostname string `json:"hostname"`
Port string `json:"port"`
PersonaName string `json:"personaHostName"`
UseTLS bool `json:"useTLS"`
CertFilename string `json:"certFilename"`
KeyFilename string `json:"keyFilename"`
SessionCookie string `json:"sessionCookie"`
PackagePath string `json:"-"`
}
var gServerConfig ServerConfig
func readConfig(file string) {
var data []byte
var err error
data, err = ioutil.ReadFile(file)
if err != nil {
log.Println("Not configured. Could not find config.json")
os.Exit(-1)
}
err = json.Unmarshal(data, &gServerConfig)
if err != nil {
log.Println("Could not unmarshal config.json", err)
os.Exit(-1)
return
}
}