https://blog.golang.org/laws-of-reflection shows how to do this, with
explanation.
-rob
On Tue, Nov 6, 2018 at 11:26 AM Eric Raymond wrote:
>
>
> On Monday, November 5, 2018 at 6:18:27 PM UTC-5, kortschak wrote:
>>
>> https://play.golang.org/p/EtXlOCR1fDY
>>
>
> Thanks, I was able to adapt tha
On Monday, November 5, 2018 at 6:18:27 PM UTC-5, kortschak wrote:
>
> https://play.golang.org/p/EtXlOCR1fDY
>
Thanks, I was able to adapt that into working code.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group a
Note that SetField will panic unless the struct value is addressable, so
you must obtain the reflect.Value from an addressable source (for example
via a pointer as in Dan's example).
On Mon, 5 Nov 2018 at 23:12, Eric Raymond wrote:
> I need an equivalent of Python setattr() - that is, set a stru
https://play.golang.org/p/EtXlOCR1fDY
On Mon, 2018-11-05 at 15:12 -0800, Eric Raymond wrote:
> I need an equivalent of Python setattr() - that is, set a struct
> member by
> string name - but the only example I've found on line (SetField
> in oleiade/reflections on GitHub) panics and dies due to w
I need an equivalent of Python setattr() - that is, set a struct member by
string name - but the only example I've found on line (SetField
in oleiade/reflections on GitHub) panics and dies due to what looks like a
spurious Elem() call. I thought I could see how to fix it, but the
resulting cod