FAQ
hi,

In the below example there is no *","* in the last field.How can I find
it?the code that I wrote is below..



"indirizzo": {
           "-tipo": "casa",
           "#text": "Viale Carlo Espinasse 5, Como"
         },


*if e.Field(i).Kind() == reflect.String { *


  * fmt.Printf("%q : ", strings.ToLower(e.Type().Field(i).Name))*

* fmt.Printf("\"%s\"", e.Field(i).Interface())*

* fmt.Printf(",")*


  * }*


--
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/groups/opt_out.

Search Discussions

  • Dan Kortschak at Jan 24, 2014 at 7:21 pm
    You are presumably iterating over the struct elements, so just look at the iteration counter and compare it to the number of element reflect tells you the type has.

    On 25/01/2014, at 4:27 AM, "kate Fernando" wrote:


    hi,

    In the below example there is no "," in the last field.How can I find it?the code that I wrote is below..



    "indirizzo": {
               "-tipo": "casa",
               "#text": "Viale Carlo Espinasse 5, Como"
             },


    if e.Field(i).Kind() == reflect.String {


                 fmt.Printf("%q : ", strings.ToLower(e.Type().Field(i).Name))

                 fmt.Printf("\"%s\"", e.Field(i).Interface())

                 fmt.Printf(",")


             }


    --
    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/groups/opt_out.

    --
    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/groups/opt_out.
  • Francesc Campoy Flores at Jan 24, 2014 at 9:36 pm
    What are you trying to do exactly?

    On Fri, Jan 24, 2014 at 9:56 AM, kate Fernando wrote:


    hi,

    In the below example there is no *","* in the last field.How can I find
    it?the code that I wrote is below..



    "indirizzo": {
    "-tipo": "casa",
    "#text": "Viale Carlo Espinasse 5, Como"
    },


    *if e.Field(i).Kind() == reflect.String { *


    * fmt.Printf("%q : ", strings.ToLower(e.Type().Field(i).Name))*

    * fmt.Printf("\"%s\"", e.Field(i).Interface())*

    * fmt.Printf(",")*


    * }*


    --
    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/groups/opt_out.


    --
    --
    Francesc Campoy
    http://campoy.cat

    --
    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/groups/opt_out.
  • Dan Kortschak at Jan 24, 2014 at 11:36 pm
    She has an assignment to marshal types to JSON using reflect, i.e. no encoding/json. This part looks like dealing with the fact that JSON elements are comma-separated rather than comma-terminated.

    {strings,bytes}.Join might be an easy way to get what is wanted.

    On 25/01/2014, at 8:06 AM, "Francesc Campoy Flores" wrote:

    What are you trying to do exactly?


    On Fri, Jan 24, 2014 at 9:56 AM, kate Fernando wrote:

    hi,

    In the below example there is no "," in the last field.How can I find it?the code that I wrote is below..



    "indirizzo": {
               "-tipo": "casa",
               "#text": "Viale Carlo Espinasse 5, Como"
             },


    if e.Field(i).Kind() == reflect.String {


                 fmt.Printf("%q : ", strings.ToLower(e.Type().Field(i).Name))

                 fmt.Printf("\"%s\"", e.Field(i).Interface())

                 fmt.Printf(",")


             }


    --
    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/groups/opt_out.



    --
    --
    Francesc Campoy
    http://campoy.cat

    --
    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/groups/opt_out.

    --
    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/groups/opt_out.
  • kate Fernando at Jan 25, 2014 at 1:51 am
    Thankyou very much for all your help.......

    --
    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/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 24, '14 at 5:56p
activeJan 25, '14 at 1:51a
posts5
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase