Example #1
0
func ReadYmlReader(r io.Reader) (cnf map[string]interface{}, err error) {
	err = nil
	buf, err := ioutil.ReadAll(r)
	if err != nil {
		return
	}
	err = goyaml.Unmarshal(buf, &cnf)
	return
}
Example #2
0
func ReadYml(path string) (cnf map[string]interface{}, err error) {
	err = nil
	buf, err := ioutil.ReadFile(path)
	if err != nil {
		return
	}
	err = goyaml.Unmarshal(buf, &cnf)
	return
}
Example #3
0
func loadConfig() *Config {
	fmt.Println("setting client_id and client_secret from configs..")
	file, err := os.Open("config.yml")
	if err == nil {
		fmt.Println("File opened without error, getting them there.")
		defer file.Close()

		r := bufio.NewReader(file)
		contents := make([]byte, 1024)
		numberOfBytes, _ := r.Read(contents)
		yerr := goyaml.Unmarshal(contents[:numberOfBytes], &config)
		if yerr != nil {
			panic(yerr)
		}
	} else {
		config.ClientId = os.Getenv("CLIENT_ID")
		config.ClientSecret = os.Getenv("CLIENT_SECRET")
		fmt.Println("could not find config.yml! hope you set them in the ENV...")
	}

	fmt.Println("config loaded in to be this client id and secret: ", config)
	return &config
}