Am 29.12.2012 12:32 schrieb "Rémy Oudompheng" <remyoud...@gmail.com>:
>
> On 2012/12/29 Johann Höchtl <johann....@gmail.com>:
> > I figured out I can iterate through the fields of a struct in this Goplay:
> >
> > http://play.golang.org/p/NJXaPCJbvB
> >
> > However I wonder why reflect.FieldByIndex takes a slice instead of a plain
> > integer,
> > or I missed a better way iterating over the struct fields. E.g. I expected
> > to see a []Value slice at some point.
>
> You seem to be looking for the Field(int) method, which takes a plain integer.
Oh my, now it's obvious.
> FieldByIndex([]int{1,2,3}) is meant to access x.Blah.Foo.Bar where
> Blah, Foo, Bar are the 1st, 2nd, 3rd fields of their structs.
Powerful abstraction.
>
> Rémy.