[英]interface conversion panic when method is not actually missing
Somehow, at runtime, I am getting the following panic message, even if it appears to me the method is properly defined to the struct that implements that interface. 不知何故,在运行时,我收到以下恐慌消息,即使在我看来该方法已正确定义到实现该接口的结构。
panic: interface conversion: schema.MerchantResultset
is not search.ResultsetInterface: missing method Add
This is the interface blueprint 这是界面蓝图
type ResultsetInterface interface {
Init(string)
CacheSet(context.Context) error
CacheSetPart(context.Context, int) error
CacheGet(context.Context, string) error
Add(interface{})
AddResultset(interface{})
}
The following is the method that is reported missing during runtime, which is assigned to my struct MerchantResultset. 以下是在运行时报告丢失的方法,该方法分配给我的struct MerchantResultset。
func (mr *MerchantResultset) Add(item interface{}) {
mr.Data = append(mr.Data, item.(Merchant))
}
I am somehow very puzzled trying to understand what is actually being needed here 我在某种程度上非常困惑,试图了解这里实际需要什么
可能是因为您传递的是MerchantResultset
,但Add
方法仅针对指向该类型的指针定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.