I don't know what is the reason of following compilation error. I will appreciate any help.
./router.go:190: cannot use listener (type webhooklistener.MyListener) as type webhook.Listener in field value:
webhooklistener.MyListener does not implement webhook.Listener (missing webhook.handle method)
have webhooklistener.handle()
want webhook.handle()
Client:
package webhook
type Listener interface {
handle()
}
type Client struct {
Listener Listener
}
Listener:
package webhooklistener
type MyListener struct {
}
func (ll MyListener) handle() {
}
Router:
listener := webhooklistener.MyListener{}
client := webhook.Client{listener} // COMPILATION ERROR
webhook.Listener
's only method is unexported, so only identifiers in that package can implement it. If you want types in other packages to be able to implement it, you need to make it exported:
type Listener interface {
Handle()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With