megauploader/confload.go

27 lines
530 B
Go
Raw Normal View History

2017-09-23 19:46:58 +02:00
package megauploader
import (
"io/ioutil"
"os"
"github.com/pkg/errors"
yaml "gopkg.in/yaml.v2"
)
// ParseConf will read and load a config file
func ParseConf(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")
}
var c Config
err = yaml.UnmarshalStrict(content, &c)
return c, err
}