Github user Jens-G commented on a diff in the pull request:
https://github.com/apache/thrift/pull/1311#discussion_r128901829
--- Diff: compiler/cpp/src/thrift/generate/t_go_generator.cc ---
@@ -424,6 +424,52 @@ bool t_go_generator::is_pointer_field(t_field* tfield,
bool in_container_value)
throw "INVALID TYPE IN type_to_go_type: " + type->get_name();
}
+string t_go_generator::gen_opt_const_values_(t_base_type::t_base tbase,
t_const_value *value) {
+ string go_value_str = "&(&struct{x ";
+ switch (tbase) {
+ case t_base_type::TYPE_BOOL:
+ go_value_str += "bool}{";
+ go_value_str += (value->get_integer() > 0 ? "true" : "false");
+ break;
+
+ case t_base_type::TYPE_I8:
+ go_value_str += "int8}{";
+ go_value_str += std::to_string(static_cast<long
long>(value->get_integer()));
+ break;
--- End diff --
Three questions:
a) Why are these casts needed?
b) Can we move that whole method next to the other method?
c) Why do we need two separate methods at all?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---