I meant v = ... On Monday, September 5, 2016 at 8:11:00 PM UTC+2, Roberto Zanotto wrote: > > I suppose you want to allocate a new value, since fd is nil: > fd = reflect.New(reflect.TypeOf(fd).Elem()) > > On Monday, September 5, 2016 at 7:28:13 PM UTC+2, dc0d wrote: >> >> How can I fill a pointer to point to the zero value of underlying type? >> >> Like in: >> >> if fd.Kind() == reflect.Ptr { >> if fd.IsNil() { >> // how to set v (pointer) to point to a zero value of underlying type? >> // using this: >> // v = reflect.Zero(fd.Type()).Interface() >> // still gives a nil value. >> } else { >> v = fd.Interface() >> } >> } >> >> >> >> I want to fill v with the zero value of the underlying direct type. >> >
-- 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.