Equals interface

227 views
Skip to first unread message

Brian Slesinsky

unread,
Nov 23, 2009, 3:32:48 AM11/23/09
to golang-nuts
I thought about writing a checkEquals method for testing and realized
this would be awkward due to the lack of a common Equals interface. I
could do it for my own types but would have to wrap primitive types or
write separate functions for them, which seems awkward. Perhaps Go
should have a standard Equals?

- Brian

Michael Elkins

unread,
Nov 23, 2009, 12:21:04 PM11/23/09
to golang-nuts
Brian,

The DeepEqual function might be what you are looking for.

http://golang.org/pkg/reflect/#DeepEqual

me

Marcin 'Qrczak' Kowalczyk

unread,
Nov 23, 2009, 4:27:18 PM11/23/09
to Michael Elkins, golang-nuts
2009/11/23 Michael Elkins <michael...@gmail.com>:

> The DeepEqual function might be what you are looking for.
>
> http://golang.org/pkg/reflect/#DeepEqual

It is not extensible to types where memberwise equality is incorrect
(e.g. most cases of dictionaries and sets represented as hash tables
or balanced trees where the precise arrangement of values depends on
insertion order and should not influence the result).

--
Marcin Kowalczyk
Reply all
Reply to author
Forward
0 new messages