- Notifications
You must be signed in to change notification settings - Fork63
Open
Description
System (please complete the following information):
- OS:
macOS
- GO Version:
1.22.1
- Pkg Version:
1.1.2
Describe the bug
panic: interface conversion: event.Event is *event.BasicEvent, not *main.MmyEvent
To Reproduce
package mainimport ("fmt""github.com/gookit/event")typeMyEventstruct {event.BasicEventcustomDatastring}func (e*MyEvent)CustomData()string {returne.customData}funcmain() {e:=&MyEvent{customData:"hello"}e.SetName("e1")event.AddEvent(e)// add listenerevent.On("e1",event.ListenerFunc(func(e event.Event)error {fmt.Printf("custom Data: %s\n",e.(*MyEvent).CustomData())returnnil}))// triggerevent.Fire("e1",nil)}
panic: interface conversion: event.Event is *event.BasicEvent, not *main.MyEventgoroutine 1 [running]:main.main.func1({0x102873790?, 0x140001102d0?}) /Users/m.arduanov/go/src/tt/main.go:25 +0xa4github.com/gookit/event.ListenerFunc.Handle(0x1400012e048?, {0x102873790?, 0x140001102d0?}) /Users/m.arduanov/go/pkg/mod/github.com/gookit/event@v1.1.2/listener.go:18 +0x34github.com/gookit/event.(*Manager).fireSimpleMode(0x14000136000, {0x102828f15, 0x2}, {0x102873790, 0x140001102d0}) /Users/m.arduanov/go/pkg/mod/github.com/gookit/event@v1.1.2/manager.go:269 +0xb4github.com/gookit/event.(*Manager).FireEvent(0x14000136000, {0x102873790, 0x140001102d0}) /Users/m.arduanov/go/pkg/mod/github.com/gookit/event@v1.1.2/manager.go:243 +0x12cgithub.com/gookit/event.(*Manager).fireByName(0x14000136000, {0x102828f15?, 0x2?}, 0x0, 0x0) /Users/m.arduanov/go/pkg/mod/github.com/gookit/event@v1.1.2/manager.go:221 +0x1d0github.com/gookit/event.(*Manager).Fire(...) /Users/m.arduanov/go/pkg/mod/github.com/gookit/event@v1.1.2/manager.go:173github.com/gookit/event.Fire(...) /Users/m.arduanov/go/pkg/mod/github.com/gookit/event@v1.1.2/std.go:67main.main() /Users/m.arduanov/go/src/tt/main.go:30 +0xd0exit status 2
Expected behavior
Listener get MyEvent with CustomData()