goyaml

Differences between revisions 1 and 16 (spanning 15 versions)
Revision 1 as of 2011-01-12 13:34:07
Size: 2813
Editor: 201-35-72-156
Comment:
Revision 16 as of 2014-03-05 20:16:43
Size: 185
Editor: bd0797ee
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== What is it? == Details about the Go yaml package were moved to the GitHub project page:
Line 3: Line 3:
The goyaml package enables [[http://golang.org|Go]] programs to very comfortably
encode and decode YAML values.
    https://github.com/go-yaml/go-yaml-v1
Line 6: Line 5:
It was developed within Canonical as part of an experiment related to using
the Go language with the [[https://launchpad.net/ensemble|Ensemble]] 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.

== API documentation ==

The API documentation is currently available at:

    http://goneat.org/pkg/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 (
    "goyaml"
    "fmt"
)

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

type T struct {
    A string
    B struct{C int; D []int "/f"}
}

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

    d, err := goyaml.Marshal(&t)
    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.String())
    }
    fmt.Printf("--- m:\n%v\n\n", m)

    d, err = goyaml.Marshal(&m)
    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]


--- m:
map[a:Easy! b:map[c:2 d:[3 4]]]

--- 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 ==

Using goinstall doesn't yet work in this case because goyaml depends
on cgo, so for now we'll simply go ahead and build it manually.

First, grab the code from Launchpad:
{{{
$ bzr branch lp:goyaml
}}}

Then, build and install it:
{{{
$ make install
}}}

== 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>
The import path for the package is now **gonuts.org/v1/yaml**.

Details about the Go yaml package were moved to the GitHub project page:

The import path for the package is now **gonuts.org/v1/yaml**.

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