go的rpc出现提示:method Xxx has wrong number of ins: 1

the way to go的$19.8和$19.9里面的demo:goto_5

$go version
go version go1.1.2 darwin/amd64

$./goto_v5 -http=:8081 -rpc=true  //启动master的时候,会显示下面一行提示:

2014/12/02 22:36:29 method Count has wrong number of ins: 1


func (s *URLStore) Put(url, key *string) error {
	for {
		*key = genKey(s.Count())
		if err := s.Set(key, url); err == nil {
			break


		}
	}
	if s.save != nil {
		s.save <- record{*key, *url}
	}
	return nil


}


func (s *URLStore) Count() int {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return len(s.urls)
}


出现这个提示的原因是:

1.RPC can only work through methods with the form (t is a value of type T): 

func (t T) Name(args *ArgType, reply *ReplyType) error

2.Count()这个函数本来是私有的,但是错误的public了。而且函数的参数和返回类型跟RPC能处理的Public函数要求不一致。

goto_v1~goto_v4这4个版本没有加rpc的时候,没问题。

goto_v5用了rpc,就把这个问题暴露出来了。

解决办法:

把这两个地方的Count改成count,重新编译,运行就ok了!


参考: https://code.google.com/p/go/issues/detail?id=1056


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值