Skip to content

YAML for Go

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE
MIT
libyaml-LICENSE
Notifications You must be signed in to change notification settings

10gen/candiedyaml

This branch is 10 commits ahead of, 5 commits behind cloudfoundry-attic/candiedyaml:master.

Folders and files

NameName
Last commit message
Last commit date
Apr 7, 2016
May 11, 2014
Feb 3, 2015
Mar 25, 2016
Jan 27, 2016
Mar 27, 2014
Mar 27, 2014
Oct 5, 2021
Oct 5, 2021
Aug 3, 2020
Jul 11, 2015
Mar 22, 2016
May 4, 2023
May 4, 2023
Jan 29, 2014
Mar 27, 2014
Apr 28, 2015
Mar 27, 2014
Apr 28, 2015
Oct 5, 2021
Oct 5, 2021
Mar 27, 2014
Apr 6, 2016
Apr 28, 2015
Dec 24, 2015
Mar 27, 2014
Mar 31, 2014
Mar 27, 2014
Mar 15, 2015

Repository files navigation

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
}

About

YAML for Go

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE
MIT
libyaml-LICENSE

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%