Go RPC appears prompt: Method Xxx has wrong number of ins:1

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

The $19.8 and $19.9 inside of the "Go" demo:goto_5

$go version
Go version go1.1.2 darwin/amd64

$./goto_v5-http=:8081-rpc=true//When you start master, the following line is displayed:

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.runlo CK () return Len (S.urls)}


The reason for this prompt is:

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 () This function is inherently private, but the error is public. Moreover, the parameters and return types of the function are inconsistent with the public function requirements that RPC can handle.

Goto_v1~goto_v4 These 4 versions did not add RPC, no problem.

GOTO_V5 used RPC to expose the problem.

Workaround:

Change the count of these two places to count, recompile, and run OK!


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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.