FAQ
Hi,

I have a YAML file. Specification allows two forms of one parameter -- a
string and a list of strings. Say:

1. notify: my_mail
2. notify:
     - my_mail_one
     - my_mail_two

I use `gopkg.in/yaml.v2` package and this struct:

type Check struct {
     ...
     Notify string `json:"-" yaml:"notify"`
     ...
}

No wonder, I can't pass a list to this. But how can I actually acomplish
this?

Thanks.

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

  • Matt Harden at Jul 13, 2015 at 11:59 pm
    This seems like a poor specification. Oh well. One way would be to make
    Notify an interface{}. If the parameter is a string the interface will be
    set to a string. If the parameter is a list of strings the interface will
    be set to a []interface{} containing strings.
    On Mon, Jul 13, 2015 at 6:00 PM Chai Tadada wrote:

    Hi,

    I have a YAML file. Specification allows two forms of one parameter -- a
    string and a list of strings. Say:

    1. notify: my_mail
    2. notify:
    - my_mail_one
    - my_mail_two

    I use `gopkg.in/yaml.v2` <http://gopkg.in/yaml.v2> package and this
    struct:

    type Check struct {
    ...
    Notify string `json:"-" yaml:"notify"`
    ...
    }

    No wonder, I can't pass a list to this. But how can I actually acomplish
    this?

    Thanks.

    --
    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.
  • Chai Tadada at Jul 14, 2015 at 12:22 am
    Thank you very much, Matt.

    That worked.

    --
    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
postedJul 13, '15 at 11:00p
activeJul 14, '15 at 12:22a
posts3
users2
websitegolang.org

2 users in discussion

Chai Tadada: 2 posts Matt Harden: 1 post

People

Translate

site design / logo © 2022 Grokbase