FAQ
Hello,

I worte a new package: https://github.com/smallfish/simpleyaml, similar as
go-simplejson <https://github.com/bitly/go-simplejson>.

REQUIRED:

    gopkg.in/yaml.v2


INSTALL:

go get -u gopkg.in/yaml.v2 # required
go get -u github.com/smallfish/simpleyaml


EXAMPLE:

var data = []byte(`
name: smallfish
age: 99
bool: true
emails:
    - xxx@xx.com
    - yyy@yy.com
bb:
     cc:
         dd:
             - 111
             - 222
             - 333
         ee: aaa
`)

y, err := NewYaml(data)
if err != nil {
         // ERROR
}

name, err := y.Get("name").String()
if err != nil {
         // ERROR
}
fmt.Println("name:", name)

// y.Get("age").Int()

// y.Get("bool").Bool()

// y.Get("bb").Get("cc").Get("ee").String()

// y.Get("bb").Get("cc").Get("ee").GetIndex(1).Int()


--
smallfish http://chenxiaoyu.org

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Michel Casabianca at Jan 15, 2015 at 4:54 pm
    Hi Gophers,

    I have added this software in my article about GO YAML Parsers:

       http://sweetohm.net/html/go-yaml-parsers.en.html

    Enjoy!

    2015-01-15 3:03 GMT+01:00 smallfish <smallfish.xy@gmail.com>:
    Hello,

    I worte a new package: https://github.com/smallfish/simpleyaml, similar
    as go-simplejson <https://github.com/bitly/go-simplejson>.

    REQUIRED:

    gopkg.in/yaml.v2


    INSTALL:

    go get -u gopkg.in/yaml.v2 # required
    go get -u github.com/smallfish/simpleyaml


    EXAMPLE:

    var data = []byte(`
    name: smallfish
    age: 99
    bool: true
    emails:
    - xxx@xx.com
    - yyy@yy.com
    bb:
    cc:
    dd:
    - 111
    - 222
    - 333
    ee: aaa
    `)

    y, err := NewYaml(data)
    if err != nil {
    // ERROR
    }

    name, err := y.Get("name").String()
    if err != nil {
    // ERROR
    }
    fmt.Println("name:", name)

    // y.Get("age").Int()

    // y.Get("bool").Bool()

    // y.Get("bb").Get("cc").Get("ee").String()

    // y.Get("bb").Get("cc").Get("ee").GetIndex(1).Int()


    --
    smallfish http://chenxiaoyu.org

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    Michel Casabianca

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Gustavo Niemeyer at Jan 15, 2015 at 5:52 pm
    Hey Michael,

    Would you mind to update the reference to yaml to version v2? (
    gopkg.in/yaml.v2)

    Thanks!
    On Thu Jan 15 2015 at 2:54:12 PM Michel Casabianca wrote:

    Hi Gophers,

    I have added this software in my article about GO YAML Parsers:

    http://sweetohm.net/html/go-yaml-parsers.en.html

    Enjoy!

    2015-01-15 3:03 GMT+01:00 smallfish <smallfish.xy@gmail.com>:
    Hello,

    I worte a new package: https://github.com/smallfish/simpleyaml, similar
    as go-simplejson <https://github.com/bitly/go-simplejson>.

    REQUIRED:

    gopkg.in/yaml.v2


    INSTALL:

    go get -u gopkg.in/yaml.v2 # required
    go get -u github.com/smallfish/simpleyaml


    EXAMPLE:

    var data = []byte(`
    name: smallfish
    age: 99
    bool: true
    emails:
    - xxx@xx.com
    - yyy@yy.com
    bb:
    cc:
    dd:
    - 111
    - 222
    - 333
    ee: aaa
    `)

    y, err := NewYaml(data)
    if err != nil {
    // ERROR
    }

    name, err := y.Get("name").String()
    if err != nil {
    // ERROR
    }
    fmt.Println("name:", name)

    // y.Get("age").Int()

    // y.Get("bool").Bool()

    // y.Get("bb").Get("cc").Get("ee").String()

    // y.Get("bb").Get("cc").Get("ee").GetIndex(1).Int()


    --
    smallfish http://chenxiaoyu.org

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    Michel Casabianca

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Michel Casabianca at Jan 15, 2015 at 6:30 pm
    Hi Gustavo,

    The article is up to date now. Thanks for your feedback. Please feel free
    to send me any thoughs about this parsers overview; any contribution is
    welccome!

    Best regards

    2015-01-15 18:52 GMT+01:00 Gustavo Niemeyer <gustavo@niemeyer.net>:
    Hey Michael,

    Would you mind to update the reference to yaml to version v2? (
    gopkg.in/yaml.v2)

    Thanks!

    On Thu Jan 15 2015 at 2:54:12 PM Michel Casabianca <
    michel.casabianca@gmail.com> wrote:
    Hi Gophers,

    I have added this software in my article about GO YAML Parsers:

    http://sweetohm.net/html/go-yaml-parsers.en.html

    Enjoy!

    2015-01-15 3:03 GMT+01:00 smallfish <smallfish.xy@gmail.com>:
    Hello,

    I worte a new package: https://github.com/smallfish/simpleyaml, similar
    as go-simplejson <https://github.com/bitly/go-simplejson>.

    REQUIRED:

    gopkg.in/yaml.v2


    INSTALL:

    go get -u gopkg.in/yaml.v2 # required
    go get -u github.com/smallfish/simpleyaml


    EXAMPLE:

    var data = []byte(`
    name: smallfish
    age: 99
    bool: true
    emails:
    - xxx@xx.com
    - yyy@yy.com
    bb:
    cc:
    dd:
    - 111
    - 222
    - 333
    ee: aaa
    `)

    y, err := NewYaml(data)
    if err != nil {
    // ERROR
    }

    name, err := y.Get("name").String()
    if err != nil {
    // ERROR
    }
    fmt.Println("name:", name)

    // y.Get("age").Int()

    // y.Get("bool").Bool()

    // y.Get("bb").Get("cc").Get("ee").String()

    // y.Get("bb").Get("cc").Get("ee").GetIndex(1).Int()


    --
    smallfish http://chenxiaoyu.org

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    Michel Casabianca

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

    --
    Michel Casabianca

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 15, '15 at 2:03a
activeJan 15, '15 at 6:30p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase