Hello, The current Go compiler implementation in Thrift does not deal correctly with optional struct values. This, for example, makes compiling the Cassandra Thrift interface unusable, because it sends along optional string values as zero length strings, when it should in fact be skipping the field altogether.
I am working on a patch to fix this. For many Go datatypes this is straight forward (ie types that can be represented as nil in Go). However, it is not clear to me how to generate Go code that does the optional check for string and integer types -- specifically to allow a string zero length string or an integer of value 0 in an optional field, versus the non inclusion of those values. This is because Go sets integer and string types to 0 and "", respectively, as their default values. Literally, I do not know how to: // Create the code to make a decision as to include or not include a struct field in // t_go_compiler.cc: generate_go_struct_writer if (item->get_req() == t_field::T_OPTIONAL && /* type is int and zero, what to do? */( { } Any suggestions would be appreciated. Thank you. Trevor Smith