Re: [go-nuts] Using reflect to call functions on struct members

2018-01-18 Thread Boone Severson
Ok, asked and answered. Figuring out .Addr() was a key, as was finding the magic incantation to get a handle to a method. I'm curious if there's a better method. https://play.golang.org/p/49Yj9G0egRI package main import ( "fmt" "reflect" ) type FooTypeA uint8 type FooTypeB uint8 type MyStruc

Re: [go-nuts] Using reflect to call functions on struct members

2018-01-18 Thread Boone Severson
4 AM UTC-8, Ayan George wrote: > > > On 01/18/2018 01:28 PM, Boone Severson wrote: > > Hi, > > > > I've got structs containing custom types. I'm hoping to use reflect > > to create some fairly generic code to Validate() every field of a > > struc

[go-nuts] Using reflect to call functions on struct members

2018-01-18 Thread Boone Severson
Hi, I've got structs containing custom types. I'm hoping to use reflect to create some fairly generic code to Validate() every field of a struct based on its type, but I can't seem to get the code right. Is this possible? I've set up a playground to show where I've gotten. https://play.golang