|
@@ -9,8 +9,8 @@ import (
|
|
|
yaml "gopkg.in/yaml.v2"
|
|
|
)
|
|
|
|
|
|
-// ParseConf will read and load a config file
|
|
|
-func ParseConf(filename string) (Config, error) {
|
|
|
+// ParseConfFile will read and load a config file
|
|
|
+func ParseConfFile(filename string) (Config, error) {
|
|
|
buf, err := os.Open(filename)
|
|
|
if err != nil {
|
|
|
return Config{}, errors.Wrap(err, "Error opening config file")
|
|
@@ -20,7 +20,18 @@ func ParseConf(filename string) (Config, error) {
|
|
|
if err != nil {
|
|
|
return Config{}, errors.Wrap(err, "Error reading config file")
|
|
|
}
|
|
|
+ return ParseConf(content)
|
|
|
+}
|
|
|
+
|
|
|
+// ParseConf will parse configuration content
|
|
|
+func ParseConf(content []byte) (Config, error) {
|
|
|
var c Config
|
|
|
- err = yaml.UnmarshalStrict(content, &c)
|
|
|
- return c, err
|
|
|
+ err := yaml.UnmarshalStrict(content, &c)
|
|
|
+ if err != nil {
|
|
|
+ return c, err
|
|
|
+ }
|
|
|
+ if c.UserHome == nil {
|
|
|
+ c.UserHome = new(UserHome)
|
|
|
+ }
|
|
|
+ return c, nil
|
|
|
}
|