コード例 #1
0
ファイル: yaml.go プロジェクト: crackcomm/go-actions
// Decode - Decodes an action from a reader.
func (d *Decoder) Decode() (a *action.Action, err error) {
	node, err := yaml.Parse(d.Reader)
	if err != nil {
		return nil, err
	}
	return nodeToAction(node), nil
}
コード例 #2
0
ファイル: parse.go プロジェクト: uniqush/uniqush-conn
func Parse(reader io.Reader) (config *Config, err error) {
	root, err := yaml.Parse(reader)
	if err != nil {
		return
	}
	return parseConfigRootNode(root)
}
コード例 #3
0
ファイル: yaml.go プロジェクト: crackcomm/go-actions
// UnmarshalMany - Unmarshals YAML actions into a Map.
func UnmarshalMany(body []byte) (map[string]*action.Action, error) {
	buffer := bytes.NewBuffer(body)
	node, err := yaml.Parse(buffer)
	if err != nil {
		return nil, err
	}
	return nodeToActions(node), nil
}
コード例 #4
0
ファイル: yaml.go プロジェクト: jonboulle/glide
// ParseYamlString parses a YAML string. This is similar but different to
// ParseYaml that parses an external file.
//
// Params:
//	- yaml (string): YAML as a string.
//
// Returns:
//	- *Config: The configuration.
func ParseYamlString(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
	yamlString := p.Get("yaml", "").(string)

	// Unfortunately, this does not wrap the root in a YAML file object.
	root, err := yaml.Parse(bytes.NewBufferString(yamlString))
	if err != nil {
		return nil, err
	}

	return FromYaml(root)
}
コード例 #5
0
ファイル: s3_repository.go プロジェクト: posix4e/capstan
func RemoteFileInfo(path string) *FileInfo {
	resp, err := http.Get(bucket_url + path)
	if err != nil {
		return nil
	}

	parts := strings.Split(path, "/")
	defer resp.Body.Close()
	result, err := yaml.Parse(resp.Body)
	if err != nil {
		return nil
	}
	return yamlToInfo(parts[0], parts[1], result)
}