Github user johnboiles commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/1382#discussion_r160477076
  
    --- Diff: compiler/cpp/src/thrift/generate/t_go_generator.cc ---
    @@ -1953,177 +1960,75 @@ void 
t_go_generator::generate_service_client(t_service* tservice) {
         f_types_ << indent() << "func (p *" << serviceName << "Client) "
                    << function_signature_if(*f_iter, "", true) << " {" << endl;
         indent_up();
    -    /*
    -    f_types_ <<
    -      indent() << "p.SeqId += 1" << endl;
    -    if (!(*f_iter)->is_oneway()) {
    -      f_types_ <<
    -        indent() << "d := defer.Deferred()" << endl <<
    -        indent() << "p.Reqs[p.SeqId] = d" << endl;
    -    }
    -    */
    -    f_types_ << indent() << "if err = p.send" << funname << "(";
    -    bool first = true;
    -
    -    for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
    -      if (first) {
    -        first = false;
    -      } else {
    -        f_types_ << ", ";
    -      }
     
    -      f_types_ << variable_name_to_go_name((*fld_iter)->get_name());
    -    }
    -
    -    f_types_ << "); err != nil { return }" << endl;
    -
    -    if (!(*f_iter)->is_oneway()) {
    -      f_types_ << indent() << "return p.recv" << funname << "()" << endl;
    -    } else {
    -      f_types_ << indent() << "return" << endl;
    -    }
    -
    -    indent_down();
    -    f_types_ << indent() << "}" << endl << endl;
    -    f_types_ << indent() << "func (p *" << serviceName << "Client) send"
    -               << function_signature(*f_iter) << "(err error) {" << endl;
    -    indent_up();
    -    std::string argsname = publicize((*f_iter)->get_name() + "_args", 
true);
    -    // Serialize the request header
    -    f_types_ << indent() << "oprot := p.OutputProtocol" << endl;
    -    f_types_ << indent() << "if oprot == nil {" << endl;
    -    f_types_ << indent() << "  oprot = 
p.ProtocolFactory.GetProtocol(p.Transport)" << endl;
    -    f_types_ << indent() << "  p.OutputProtocol = oprot" << endl;
    -    f_types_ << indent() << "}" << endl;
    -    f_types_ << indent() << "p.SeqId++" << endl;
    -    f_types_ << indent() << "if err = oprot.WriteMessageBegin(\"" << 
(*f_iter)->get_name()
    -               << "\", " << ((*f_iter)->is_oneway() ? "thrift.ONEWAY" : 
"thrift.CALL")
    -               << ", p.SeqId); err != nil {" << endl;
    -    indent_up();
    -    f_types_ << indent() << "  return" << endl;
    -    indent_down();
    -    f_types_ << indent() << "}" << endl;
    -    f_types_ << indent() << "args := " << argsname << "{" << endl;
    +    std::string method = (*f_iter)->get_name();
    +    std::string argsType = publicize(method + "_args", true);
    +    std::string argsName = tmp("_args");
    +    f_types_ << indent() << "var " << argsName << " " << argsType << endl;
     
         for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
    -      f_types_ << indent() << publicize((*fld_iter)->get_name()) << " : "
    -                 << variable_name_to_go_name((*fld_iter)->get_name()) << 
"," << endl;
    +      f_types_ << indent() << argsName << "." << 
publicize((*fld_iter)->get_name())
    +               << " = " << 
variable_name_to_go_name((*fld_iter)->get_name()) << endl;
         }
    -    f_types_ << indent() << "}" << endl;
    -
    -    // Write to the stream
    -    f_types_ << indent() << "if err = args." << write_method_name_ << 
"(oprot); err != nil {" << endl;
    -    indent_up();
    -    f_types_ << indent() << "  return" << endl;
    -    indent_down();
    -    f_types_ << indent() << "}" << endl;
    -    f_types_ << indent() << "if err = oprot.WriteMessageEnd(); err != nil 
{" << endl;
    -    indent_up();
    -    f_types_ << indent() << "  return" << endl;
    -    indent_down();
    -    f_types_ << indent() << "}" << endl;
    -    f_types_ << indent() << "return oprot.Flush()" << endl;
    -    indent_down();
    -    f_types_ << indent() << "}" << endl << endl;
     
         if (!(*f_iter)->is_oneway()) {
    -      std::string resultname = publicize((*f_iter)->get_name() + 
"_result", true);
    -      // Open function
    -      f_types_ << endl << indent() << "func (p *" << serviceName << 
"Client) recv"
    -                 << publicize((*f_iter)->get_name()) << "() (";
    +      std::string resultName = tmp("_result");
    +      std::string resultType = publicize(method + "_result", true);
    +      f_types_ << indent() << "var " << resultName << " " << resultType << 
endl;
    +      f_types_ << indent() << "if err = p.c.Call(ctx, \""
    --- End diff --
    
    When using one of the now-deprecated initializers, this line will cause a 
panic, since `p.c` is nil. The deprecated initializers create the `TClient` at 
`p.BaseMyServiceClient.c`


---

Reply via email to