Example #1
0
func readLocalYaml(yamlfile string) (map[interface{}]interface{}, error) {

	data := make(map[interface{}]interface{})

	buf, err := ioutil.ReadFile(yamlfile)
	if err != nil {
		return nil, err
	}
	err = yaml.Unmarshal(buf, &data)
	if err != nil {
		return nil, err
	}

	return data, nil
}
Example #2
0
func readRemoteYaml(url string) (map[interface{}]interface{}, error) {

	data := make(map[interface{}]interface{})

	res, err1 := http.Get(url)
	if err1 != nil {
		return nil, err1
	}

	buf, err2 := ioutil.ReadAll(res.Body)
	res.Body.Close()
	if err2 != nil {
		return nil, err2
	}

	err3 := yaml.Unmarshal(buf, &data)
	if err3 != nil {
		return nil, err3
	}

	return data, nil
}