goyaml

Differences between revisions 10 and 20 (spanning 10 versions)
Revision 10 as of 2011-10-07 14:21:28
Size: 3060
Editor: 201-11-202-175
Comment:
Revision 20 as of 2014-12-09 23:24:38
Size: 682
Editor: foka
Comment: Provide some more web links for background information.
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
<<TableOfContents>> Details about the Go yaml package were moved from to http://launchpad.net/goyaml the GitHub project page:
Line 3: Line 3:
== What is it? ==     https://github.com/go-yaml/yaml/tree/v1
Line 5: Line 5:
The goyaml package enables [[http://golang.org|Go]] programs to very comfortably
encode and decode YAML values.
The import path for the package was, in March 2014, '''`"gonuts.org/v1/yaml"`''', but has since been moved to '''`"gopkg.in/yaml.v1"`'''.
Line 8: Line 7:
It was developed within Canonical as part of an experiment related to using
the Go language with the [[https://juju.ubuntu.com|juju]] project.

goyaml internally uses the C [[http://pyyaml.org/wiki/LibYAML|libyaml]] library to
parse and generate YAML data fast and reliably. It ships with all the necessary
files, though, and has no external dependencies besides Go itself.

== Compatibility ==

goyaml is almost compatible with YAML 1.1, including support for anchors, tags, etc.
There are still a few missing bits, such as document merging, base-60 floats (WTF),
and multi-document unmarshalling. These features are not hard to add, and will be
introduced as necessary.

== API documentation ==

The API documentation is currently available at:

    http://goneat.org/lp/goyaml

== Example ==

Here is a simple example which connects to !ZooKeeper, waits for the session to
be established, and attempts to create a node:
{{{
package main

import (
    "launchpad.net/goyaml"
    "fmt"
)

var data = `
a: Easy!
b:
  c: 2
  d: [3, 4]
`

type T struct {
    A string
    B struct{C int; D []int ",flow"}
}

func main() {
    t := T{}

    err := goyaml.Unmarshal([]byte(data), &t)
    if err != nil {
        panic(err)
    }
    fmt.Printf("--- t:\n%v\n\n", t)

    d, err := goyaml.Marshal(&t)
    if err != nil {
        panic(err)
    }
    fmt.Printf("--- t dump:\n%s\n\n", string(d))

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

    err = goyaml.Unmarshal([]byte(data), &m)
    if err != nil {
        panic(err)
    }
    fmt.Printf("--- m:\n%v\n\n", m)

    d, err = goyaml.Marshal(&m)
    if err != nil {
        panic(err)
    }
    fmt.Printf("--- m dump:\n%s\n\n", string(d))
}
}}}

This example will generate the following output:

{{{
--- t:
{Easy! {2 [3 4]}}

--- t dump:
a: Easy!
b:
  c: 2
  d: [3, 4]
A newer '''`"gopkg.in/yaml.v2"`''' is now also available with an expanded API. See http://blog.labix.org/2014/09/22/announcing-yaml-v2-for-go for more information.
Line 96: Line 10:
--- m:
map[a:Easy! b:map[c:2 d:[3 4]]]
== Package ==
Line 99: Line 12:
--- m dump:
a: Easy!
b:
  c: 2
  d:
  - 3
  - 4
}}}

== Source code ==

To obtain the source code, use [[http://bazaar.canonical.com|Bazaar]] to download it from Launchpad:
{{{
$ bzr branch lp:goyaml
}}}

== Reporting bugs ==

Please report bugs at:

    https://launchpad.net/goyaml

== How to build and install goyaml ==

To make use of goyaml, just run the following command:
{{{
$ goinstall launchpad.net/goyaml
}}}

== Running tests ==

To run tests, first install [[http://labix.org/gocheck|gocheck]] with:
{{{
$ goinstall launchpad.net/gocheck
}}}

Then run gotest as usual:

{{{
$ gotest
}}}

== License ==

goyaml is licensed under the LGPL.

== Contact ==

This project is being developed under the [[https://launchpad.net/ensemble|Ensemble]] project at [[http://www.canonical.com|Canonical]].

To get in touch, send a message to the Ensemble mailing list at: <ensemble@lists.ubuntu.com>
As of December 2014, the golang-goyaml-dev (0.0~bzr50-1) in Debian/Ubuntu repositories was packaged in January 2014 and corresponds to an older version maintained in a bzr repository on Launchpad.

Details about the Go yaml package were moved from to http://launchpad.net/goyaml the GitHub project page:

The import path for the package was, in March 2014, "gonuts.org/v1/yaml", but has since been moved to "gopkg.in/yaml.v1".

A newer "gopkg.in/yaml.v2" is now also available with an expanded API. See http://blog.labix.org/2014/09/22/announcing-yaml-v2-for-go for more information.

Package

As of December 2014, the golang-goyaml-dev (0.0~bzr50-1) in Debian/Ubuntu repositories was packaged in January 2014 and corresponds to an older version maintained in a bzr repository on Launchpad.

goyaml (last edited 2014-12-09 23:25:57 by foka)