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

2018-01-19 Thread jake6502
I think this 40 second snippet of a talk by Rob Pike is apropos. It is not specific to your case, but speaks of reflection in general. On Thursday, January 18, 2018 at 5:20:26 PM UTC-5, Boone Severson wrote: > > Ok, asked a

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 J. Severson
(for completeness and future reference, I found how Addr() will let me use a pointer receiver https://play.golang.org/p/JSKduIPDV2e . However, I'm still at the place I was in the Go Playground link mentioned immediately above) On Thu, Jan 18, 2018 at 11:14 AM, Boone Severson wrote: > Thank you

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

2018-01-18 Thread Boone Severson
Thank you for the response. I've chosen to have Validate() receive a copy of the value, but I still can't find Validate() in the list of Methods: https://play.golang.org/p/uCeCB-wv4Ku (run to see output) Any further advice? Thanks in advance. On Thursday, January 18, 2018 at 10:40:34 AM UTC-8,

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

2018-01-18 Thread Ayan George
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 > struct based on its type, but I can't seem to get the code right. Is > this possible? I've set up a pl

[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