You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by yu...@apache.org on 2021/02/18 21:54:14 UTC

[thrift] branch master updated: THRIFT-5353: Fix import dedup without explicit go namespace

This is an automated email from the ASF dual-hosted git repository.

yuxuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new f9177f3  THRIFT-5353: Fix import dedup without explicit go namespace
f9177f3 is described below

commit f9177f34e6a49e359193feac75762ae0bb53077f
Author: Yuxuan 'fishy' Wang <yu...@reddit.com>
AuthorDate: Thu Feb 18 11:52:27 2021 -0800

    THRIFT-5353: Fix import dedup without explicit go namespace
    
    Client: go
    
    When a thrift file includes 2 or more other thrift files, and those
    included thrift files do not have explicit go namespaces defined, the
    current import dedup logic would wrongly use their empty namespace and
    skip the second one, while the real import namespace should be inferred
    from the filename.
---
 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 2cef11f..8d25d48 100644
--- a/compiler/cpp/src/thrift/generate/t_go_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc
@@ -787,14 +787,15 @@ void t_go_generator::init_generator() {
 string t_go_generator::render_included_programs(string& unused_prot) {
   const vector<t_program*>& includes = program_->get_includes();
   string result = "";
-  string local_namespace = program_->get_namespace("go");
+  string local_namespace = get_real_go_module(program_);
   std::set<std::string> included;
   for (auto include : includes) {
-    if (!local_namespace.empty() && local_namespace == include->get_namespace("go")) {
+    std::string includeModule = get_real_go_module(include);
+    if (!local_namespace.empty() && local_namespace == includeModule) {
       continue;
     }
 
-    if (!included.insert(include->get_namespace("go")).second) {
+    if (!included.insert(includeModule).second) {
         continue;
     }