Hi everyone,
I want to append a nil value using reflect.Append(), but I got a panic:
reflect: call of reflect.Value.Set on zero Value.
This is my code.
s := make([]interface{}, 10)
v := reflect.ValueOf(nil)
reflect.Append(reflect.ValueOf(s), v)
So is there a way i can append nil? Currently I do this as workaround:
s := make([]interface{}, 10)
s0 := make([]interface{}, 1)
r := reflect.AppendSlice(reflect.ValueOf(s), reflect.ValueOf(s0))
It works but I think there must be a better way.
Best regards,
Xinhu
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.