Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Custom events failed to execute #68

Open
Assignees
inhere
Labels
bugSomething isn't working
@arduanov

Description

@arduanov

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()

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp