Why dont you turn that 2 maps into json then compare its diffrent or not
Vào lúc 21:35:38 UTC+7 ngày Thứ Ba, 18 tháng 7, 2023, Jochen Voss đã viết:
> Dear all,
>
> To implement the "eq" operator in a simple PostScript interpreter, I need
> to determine whether two maps are the same object.
>
> T
Hi,
If you are in tests context, you can have a look at go-testdeep [1] and its
Shallow operator [2] like in: https://go.dev/play/p/kNItQmDOJDy
Regards,
Max.
[1]: https://github.com/maxatome/go-testdeep/
[2]: https://go-testdeep.zetta.rocks/operators/shallow/
Le mardi 18 juillet 2023 à 17:55:5
Thanks Jason, I get your point about DeepEqual now :)
On Tuesday, 18 July 2023 at 16:52:51 UTC+1 Jason Phillips wrote:
> Also note: reflect.DeepEqual doesn't *just* compare the contents of the
> map. It only compares contents if the maps aren't "the same map object".
> From the documentation:
>
Also note: reflect.DeepEqual doesn't *just* compare the contents of the
map. It only compares contents if the maps aren't "the same map object".
>From the documentation:
> Map values are deeply equal when all of the following are true: they are
both nil or both non-nil, they have the same lengt
reflect.Value.UnsafePointer() is probably not safer than using unsafe
directly, assuming you're using unsafe in a way that doesn't break the
rules. Reflect is doing effectively the same unsafe.Pointer conversion
under the hood [1]. It's certainly easier on the eyes, in my opinion,
though.
[1]
I like that. I think it's is quite a smart way of doing it,
I don't think you need to check both maps when choosing a key. Once you've
found a candidate key in one map, you can test the other map and if it
*does* exist then the two maps aren't equal. You've then saved the
insertion and deletio