-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
38 lines (31 loc) · 851 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
package chat_application
import (
"gopkg.in/yaml.v2"
"io/ioutil"
)
type ChatConfig struct {
Host string `yaml:"host"`
Port int `yaml:"telnet_port"`
RestAPIPort int `yaml:"rest_api_port"`
LogFile string `yaml:"logfile"`
}
var chatConfig ChatConfig
// ParseConfigFile will read a yaml file which
// contains configuration information for the chat server.
// See chat.yml for the format of the yaml file.
func ParseConfigFile() error {
// TODO: for now hardcode the config file as
// chat.yml. This config file must be in the same
// directory as the chatserver binary.
// Make this configurable later.
configFileName := "chat.yml"
configFile, err := ioutil.ReadFile(configFileName)
if err != nil {
return err
}
err = yaml.Unmarshal(configFile, &chatConfig)
if err != nil {
return err
}
return nil
}