asaskevich / EventBus

[Go] Lightweight eventbus with async compatibility for Go
MIT License
1.74k stars 220 forks source link

fix(event_bus): add additional check for functions that can have same pointer #59

Closed mariiatuzovska closed 3 months ago

mariiatuzovska commented 1 year ago

Creating functions within a loop in Go can result in unexpected behavior, such as multiple functions sharing the same pointer value. The reflect.DeepEqual(handler.callBack, callback) check has been includedas a final measure to distinguish between different values, particularly when the pointers and types are identical.

HildaM commented 5 months ago

this will cause TestUnSubscribeMethod() failed, due to reflect.DeepEqual(handler.callBack, callback) == false, and idx return -1