diff --git a/src/idl_gen_go.cpp b/src/idl_gen_go.cpp index dadb350f1..88dfd2359 100644 --- a/src/idl_gen_go.cpp +++ b/src/idl_gen_go.cpp @@ -35,6 +35,13 @@ namespace flatbuffers { namespace go { +// see https://golang.org/ref/spec#Keywords +static const char *g_golang_keywords[] = { + "break", "default", "func", "interface", "select", "case", "defer", "go", + "map", "struct", "chan", "else", "goto", "package", "switch", "const", + "fallthrough", "if", "range", "type", "continue", "for", "import", "return", "var", +}; + static std::string GenGetter(const Type &type); static std::string GenMethod(const FieldDef &field); static void GenStructBuilder(const StructDef &struct_def, @@ -43,6 +50,15 @@ static void GenReceiver(const StructDef &struct_def, std::string *code_ptr); static std::string GenTypeBasic(const Type &type); static std::string GenTypeGet(const Type &type); static std::string TypeName(const FieldDef &field); +static std::string GoIdentity(const std::string& name) { + for (size_t i=0; i