Re: [go-nuts] How to append nil using reflect

2019-01-11 Thread Xinhu Liu
Hi Josh, thanks a lot. It helps me to understand interface in go. Am Sa., 12. Jan. 2019 um 00:08 Uhr schrieb Josh Humphries < jh...@bluegosling.com>: > On Fri, Jan 11, 2019 at 5:59 PM Xinhu Liu wrote: > >> Hi Ian, >> >> thanks for your reply. >> >> After reading and experimenting a lot I think

Re: [go-nuts] How to append nil using reflect

2019-01-11 Thread Josh Humphries
On Fri, Jan 11, 2019 at 5:59 PM Xinhu Liu wrote: > Hi Ian, > > thanks for your reply. > > After reading and experimenting a lot I think I understand the slight > differences between nil and interface{} with nil value. > > The only thing I find confusing is that interface{}(nil) == nil returns > t

Re: [go-nuts] How to append nil using reflect

2019-01-11 Thread Xinhu Liu
Hi Ian, thanks for your reply. After reading and experimenting a lot I think I understand the slight differences between nil and interface{} with nil value. The only thing I find confusing is that interface{}(nil) == nil returns true. (The reason why I use reflect on interface is that I want to

Re: [go-nuts] How to append nil using reflect

2019-01-10 Thread Ian Lance Taylor
On Thu, Jan 10, 2019 at 3:40 PM wrote: > > 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 i