Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions compiler/cpp/src/thrift/generate/t_go_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3112,8 +3112,13 @@ void t_go_generator::generate_service_remote(t_service* tservice) {
<< '\n';
f_remote << indent() << "containerStruct" << i << " := " << argumentsModule << ".New"
<< argumentsName << "()" << '\n';
f_remote << indent() << err2 << " := containerStruct" << i << ".ReadField" << (i + 1) << "(context.Background(), "
<< jsProt << ")" << '\n';
// The args struct names its read methods after the field id, which need not be the
// argument's position, and is negative (ReadField_N) when the IDL gives none.
int32_t field_id = args[i]->get_key();
string read_method = field_id < 0 ? "ReadField_" + std::to_string(-field_id)
: "ReadField" + std::to_string(field_id);
f_remote << indent() << err2 << " := containerStruct" << i << "." << read_method
<< "(context.Background(), " << jsProt << ")" << '\n';
f_remote << indent() << "if " << err2 << " != nil {" << '\n';
indent_up();
f_remote << indent() << "Usage()" << '\n';
Expand Down
4 changes: 4 additions & 0 deletions lib/go/test/ServicesTest.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,8 @@ service container_test_parent {

service container_test extends container_test_parent {
void child_only_func(1: set<i32> s)
// The -remote stub must read a container argument by its field id, which
// need not be its position, and is negative when the IDL gives none.
void nonpositional_id_func(1: i32 a, 3: map<string, i32> m)
void implicit_id_func(list<i32> xs)
}
Loading