I need to check all the field names and the tags of a struct, currently I
do:
> v.FieldByNameFunc(func(fieldName string) bool {
> field, _ := v.FieldByName(fieldName)
> // then do some work with field.Name and field.Tag
> return false
> })
I use *FieldByNameFunc* because it is an easy way to loop over Anonymous
fields.
By running some benchmark I see that this code is quite slow because it
seem *FieldByName* will call *FieldByNameFunc* again (not really sure this
is true or this is the cause, just guess).
I think what I'm going to do is a recursive function that use *NumField() *and
*Field(int) *instead but before that I think I should ask for someone
really know to work with reflection.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.