Example #1
0
func loadFile(path string, pointer interface{}) {
	Console.Meh("Loading " + path)
	buffer, readErr := ioutil.ReadFile(path)
	if readErr != nil {
		Console.Broke(readErr)
	}
	marshErr := goyaml.Unmarshal(buffer, pointer)
	if marshErr != nil {
		Console.Broke(marshErr)
	}
}
Example #2
0
func NewConfig() Config {
	cfg := Config{}

	config_file := os.Getenv("HPR_CONF")
	if strings.EqualFold(config_file, "") {
		config_file = "/etc/hpr/hpr.yml"
	}
	f, err := ioutil.ReadFile(config_file)
	CheckPanic(err, "Unable to open YAML file")

	err = goyaml.Unmarshal(f, &cfg.Options)
	CheckPanic(err, "Unable to parse YAML file")
	return cfg
}