26 lines
530 B
Go
26 lines
530 B
Go
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
|
|
}
|