package megauploader import ( "io/ioutil" "os" "github.com/pkg/errors" yaml "gopkg.in/yaml.v2" ) // 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") } defer buf.Close() content, err := ioutil.ReadAll(buf) 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) if err != nil { return c, err } if c.UserHome == nil { c.UserHome = new(UserHome) } return c, nil }