gopherjs
                                
                                 gopherjs copied to clipboard
                                
                                    gopherjs copied to clipboard
                            
                            
                            
                        reflect breaks pointer comparison
The following sample using reflect to compare pointers works in gc, but it fails when using gopherJS.
http://play.golang.org/p/33bND01kB0
Thx for the bug report. I've neglected Addr a bit, since it's mostly used in unsafe contexts that are not supported by GopherJS. But I think your use case is valid and there should be a way to support it.
Here is a second test case that might need work: http://play.golang.org/p/8tDGNnhoXm I suspect the fix will be the same for both issues, but I'm posting this just in case
Hmm, in my first message I confused Addr with Pointer. Only Pointer is related to unsafe.
According to the documentation of reflect.Value, your first example is not guaranteed to work. It says:
"Using == on two Values does not compare the underlying values they represent, but rather the contents of the Value structs. To compare two Values, compare the results of the Interface method."
Your second example however seems correct. I'm looking into fixing it.
This seems to be working now? At least the two playground links both return 'true' for me (which I think is expected?). Should this issue be closed?
Both programs return true for me using gc, and false using GopherJS, so this issue is still unresolved.
@flimzy The playground links are at play.golang.org. Did you try gopherjs.org/playground?
https://play.golang.org/p/33bND01kB0 - true http://play.golang.org/p/8tDGNnhoXm - true
https://gopherjs.github.io/playground/#/33bND01kB0 - false https://gopherjs.github.io/playground/#/8tDGNnhoXm - false