Repository: thrift
Updated Branches:
  refs/heads/master 24ea0bf5d -> dfc22ad20


THRIFT-3128 Go generated code produces name collisions between services
Client: Go
Patch: Adam Beberg


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/dfc22ad2
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/dfc22ad2
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/dfc22ad2

Branch: refs/heads/master
Commit: dfc22ad2059312018777265af0b8684f0173b9dc
Parents: 24ea0bf
Author: Jens Geyer <[email protected]>
Authored: Fri May 8 21:10:13 2015 +0200
Committer: Jens Geyer <[email protected]>
Committed: Fri May 8 21:43:50 2015 +0200

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_go_generator.cc |  5 +++++
 lib/go/test/NamesTest.thrift                | 12 +++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/dfc22ad2/compiler/cpp/src/generate/t_go_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_go_generator.cc 
b/compiler/cpp/src/generate/t_go_generator.cc
index c949225..b6e39a1 100644
--- a/compiler/cpp/src/generate/t_go_generator.cc
+++ b/compiler/cpp/src/generate/t_go_generator.cc
@@ -471,6 +471,11 @@ std::string t_go_generator::publicize(const std::string& 
value, bool is_args_or_
     }
   }
 
+  // Avoid naming collisions with other services
+  if (is_args_or_result) {
+    prefix += publicize(service_name_);
+  }
+
   return prefix + value2;
 }
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/dfc22ad2/lib/go/test/NamesTest.thrift
----------------------------------------------------------------------
diff --git a/lib/go/test/NamesTest.thrift b/lib/go/test/NamesTest.thrift
index b59a5e0..e7e9563 100644
--- a/lib/go/test/NamesTest.thrift
+++ b/lib/go/test/NamesTest.thrift
@@ -18,5 +18,15 @@
 #
 
 struct NamesTest {
-               1: required string type
+    1: required string type
+}
+
+service NameCollisionOne
+{
+    void blahBlah()
+}
+
+service NameCollisionTwo
+{
+    void blahBlah()
 }

Reply via email to