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 <e...@thyrsus.com> 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 what looks like a
> spurious Elem() call.  I thought I could see how to fix it, but the
> resulting code has no effect,.
>
> Would someone please point me at a working example, or post one here?
>
> --
> 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 golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to