mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-12 16:00:59 +00:00
sharing namespace_dir and the namespace string methods
This commit is contained in:
@@ -663,22 +663,10 @@ class GoGenerator : public BaseGenerator {
|
||||
bool needs_imports) {
|
||||
if (!classcode.length()) return true;
|
||||
|
||||
std::string namespace_name;
|
||||
std::string namespace_dir = path_; // Either empty or ends in separator.
|
||||
auto &namespaces = parser_.namespaces_.back()->components;
|
||||
for (auto it = namespaces.begin(); it != namespaces.end(); ++it) {
|
||||
if (namespace_name.length()) {
|
||||
namespace_name += ".";
|
||||
}
|
||||
namespace_name = *it;
|
||||
namespace_dir += *it + kPathSeparator;
|
||||
}
|
||||
EnsureDirExists(namespace_dir);
|
||||
|
||||
std::string code = "";
|
||||
BeginFile(namespace_name, needs_imports, &code);
|
||||
BeginFile(LastNamespacePart(), needs_imports, &code);
|
||||
code += classcode;
|
||||
std::string filename = namespace_dir + def.name + ".go";
|
||||
std::string filename = namespace_dir_ + def.name + ".go";
|
||||
return SaveFile(filename.c_str(), code, false);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user