niusmallnan 1d7ac008d4 Update vendor 5 年之前
..
.gitignore 1d691cd8d6 move dependencies to vendor 9 年之前
.travis.yml 1d691cd8d6 move dependencies to vendor 9 年之前
LICENSE 1d691cd8d6 move dependencies to vendor 9 年之前
README.md c0c8179813 `ros config get` shows default values 8 年之前
api.go 1d691cd8d6 move dependencies to vendor 9 年之前
decode.go 1d691cd8d6 move dependencies to vendor 9 年之前
emitter.go 1d7ac008d4 Update vendor 5 年之前
encode.go c0c8179813 `ros config get` shows default values 8 年之前
libyaml-LICENSE 1d691cd8d6 move dependencies to vendor 9 年之前
parser.go 1d691cd8d6 move dependencies to vendor 9 年之前
reader.go 1d691cd8d6 move dependencies to vendor 9 年之前
resolver.go c0c8179813 `ros config get` shows default values 8 年之前
run_parser.go 1d691cd8d6 move dependencies to vendor 9 年之前
scanner.go c0c8179813 `ros config get` shows default values 8 年之前
tags.go c0c8179813 `ros config get` shows default values 8 年之前
writer.go 1d691cd8d6 move dependencies to vendor 9 年之前
yaml_definesh.go 1d691cd8d6 move dependencies to vendor 9 年之前
yaml_privateh.go 1d691cd8d6 move dependencies to vendor 9 年之前
yamlh.go 1d691cd8d6 move dependencies to vendor 9 年之前

README.md

Build Status

candiedyaml

YAML for Go

A YAML 1.1 parser with support for YAML 1.2 features

Usage

package myApp

import (
  "github.com/cloudfoundry-incubator/candiedyaml"
  "fmt"
  "os"
)

func main() {
  file, err := os.Open("path/to/some/file.yml")
  if err != nil {
    println("File does not exist:", err.Error())
    os.Exit(1)
  }
  defer file.Close()

  document := new(interface{})
  decoder := candiedyaml.NewDecoder(file)
  err = decoder.Decode(document)
  
  if err != nil {
    println("Failed to decode document:", err.Error())
  }
  
  println("parsed yml into interface:", fmt.Sprintf("%#v", document))
  
  fileToWrite, err := os.Create("path/to/some/new/file.yml")
  if err != nil {
    println("Failed to open file for writing:", err.Error())
    os.Exit(1)
  }
  defer fileToWrite.Close()

  encoder := candiedyaml.NewEncoder(fileToWrite)
  err = encoder.Encode(document)

  if err != nil {
    println("Failed to encode document:", err.Error())
    os.Exit(1)
  }
  
  return
}