sampler-fork/config/config.go

29 lines
440 B
Go
Raw Normal View History

2019-01-25 04:10:38 +00:00
package config
import (
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
)
type Config struct {
LineCharts []LineChartConfig `yaml:"line-charts"`
}
func Load(location string) *Config {
yamlFile, err := ioutil.ReadFile(location)
if err != nil {
log.Fatalf("Can't read config file: %s", location)
}
2019-01-28 23:09:52 +00:00
cfg := new(Config)
2019-01-25 04:10:38 +00:00
err = yaml.Unmarshal(yamlFile, cfg)
if err != nil {
log.Fatalf("Can't read config file: %v", err)
}
return cfg
}