diff --git a/rpc/compiler/go_generator.cc b/rpc/compiler/go_generator.cc index 9085f4d6..bbc5a562 100644 --- a/rpc/compiler/go_generator.cc +++ b/rpc/compiler/go_generator.cc @@ -568,6 +568,8 @@ void PrintMessageImports( string pkg = GenerateFullGoPackage(fd); if (pkg != "") { auto ret = imports->insert(pkg); + // Use ret.second to guarantee if a package spans multiple files, it only + // gets 1 alias. if (ret.second && file->package() == fd->package()) { // the same package name in different directories. Require an alias. (*import_alias)[pkg] = "apb" + std::to_string(idx++);