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.
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
方法仅针对指向该类型的指针定义。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.