From b5868ed61f500a875c66b69fbb5fac7f3bff0022 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 17 Feb 2021 12:58:40 -0800 Subject: [PATCH] THRIFT-4914: Fix name redeclaration bug in compiled go code Client: go This fixes the bug reported in https://github.com/apache/thrift/pull/2315#discussion_r577919697. --- compiler/cpp/src/thrift/generate/t_go_generator.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc index d9f9d51c5af..ef0e1edfbf7 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc @@ -2170,13 +2170,14 @@ void t_go_generator::generate_service_client(t_service* tservice) { } if (!(*f_iter)->is_oneway()) { + std::string metaName = tmp("_meta"); std::string resultName = tmp("_result"); std::string resultType = publicize(method + "_result", true); f_types_ << indent() << "var " << resultName << " " << resultType << endl; - f_types_ << indent() << "var meta thrift.ResponseMeta" << endl; - f_types_ << indent() << "meta, err = p.Client_().Call(ctx, \"" + f_types_ << indent() << "var " << metaName << " thrift.ResponseMeta" << endl; + f_types_ << indent() << metaName << ", err = p.Client_().Call(ctx, \"" << method << "\", &" << argsName << ", &" << resultName << ")" << endl; - f_types_ << indent() << "p.SetLastResponseMeta_(meta)" << endl; + f_types_ << indent() << "p.SetLastResponseMeta_(" << metaName << ")" << endl; f_types_ << indent() << "if err != nil {" << endl; indent_up();