drnf09037160 2016-04-10 07:51
浏览 19
已采纳

当方法实际上没有丢失时,界面转换会出现紧急情况

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

  • 写回答

1条回答 默认 最新

  • dpfl37651 2016-04-10 07:58
    关注

    Probably it’s because you are passing around a MerchantResultset, but the Add method is only defined for a pointer to that type.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题