Thanks!

All this gets me thinking, is there any use case where this fact is useful? 
(I.e. a nil-valued interface not being equal to nil via the == operator.)

Also, should the reflect.Value.IsNil documentation 
<https://golang.org/pkg/reflect/#Value.IsNil> be updated? It doesn't 
mention this case where it differs*, only the one about it panicking on a 
zero reflect.Value.

* IsNil returns true for an interface{} with a nil value pointer, even 
though '== nil' return false.


On Tuesday, 9 August 2016 11:34:00 UTC+1, Jakob Borg wrote:
>
> 2016-08-09 10:26 GMT+02:00 Sam Salisbury <samsal...@gmail.com 
> <javascript:>>: 
> > So, for purely academic reasons, what if I wanted to write a function to 
> > look inside an interface value to determine if its value pointer is nil? 
> > 
> > I tried this, following from your simplified example Steven.... 
> > https://play.golang.org/p/oG2aQzlKfc 
> > 
> > var m map[string]interface{} 
> > var i interface{} = m                    // i is interface{}, right? 
> > id := reflect.ValueOf(i).InterfaceData() // nope, panics "call of 
> > reflect.Value.InterfaceData on map Value" 
>
> You can indirect via a pointer: 
>
> https://play.golang.org/p/NmnvqTdWHF 
>
> //jb 
>

-- 
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