7 "github.com/ghodss/yaml"
10 // LoadFile loads configuration from the file given by configPath and
11 // decodes it into cfg.
13 // YAML and JSON formats are supported.
14 func LoadFile(cfg interface{}, configPath string) error {
15 buf, err := ioutil.ReadFile(configPath)
19 err = yaml.Unmarshal(buf, cfg)
21 return fmt.Errorf("Error decoding config %q: %v", configPath, err)
26 // Dump returns a YAML representation of cfg.
27 func Dump(cfg interface{}) ([]byte, error) {
28 return yaml.Marshal(cfg)