@@ -293,10 +293,12 @@ class t_go_generator : public t_generator {
293
293
std::string package_name_;
294
294
std::string package_dir_;
295
295
296
- static std::string camelcase (const std::string& value);
297
- static std::string publicize (const std::string& value, bool is_args_or_result = false );
298
- static std::string new_prefix (const std::string& value);
299
- static std::string privatize (const std::string& value);
296
+ std::set<std::string> commonInitialisms;
297
+
298
+ std::string camelcase (const std::string& value) const ;
299
+ std::string publicize (const std::string& value, bool is_args_or_result = false ) const ;
300
+ std::string privatize (const std::string& value) const ;
301
+ std::string new_prefix (const std::string& value) const ;
300
302
static std::string variable_name_to_go_name (const std::string& value);
301
303
static bool is_pointer_field (t_field* tfield, bool in_container = false );
302
304
static bool omit_initialization (t_field* tfield);
@@ -408,14 +410,7 @@ bool t_go_generator::is_pointer_field(t_field* tfield, bool in_container_value)
408
410
throw " INVALID TYPE IN type_to_go_type: " + type->get_name ();
409
411
}
410
412
411
- // This set is taken from https://github.com/golang/lint/blob/master/lint.go#L692
412
- const std::set<std::string> commonInitialisms = {" API" , " ASCII" , " CPU" , " CSS" ,
413
- " DNS" , " EOF" , " GUID" , " HTML" , " HTTP" , " HTTPS" , " ID" , " IP" , " JSON" , " LHS" ,
414
- " QPS" , " RAM" , " RHS" , " RPC" , " SLA" , " SMTP" , " SSH" , " TCP" , " TLS" , " TTL" , " UDP" ,
415
- " UI" , " UID" , " UUID" , " URI" , " URL" , " UTF8" , " VM" , " XML" , " XSRF" , " XSS" ,};
416
-
417
- std::string t_go_generator::camelcase (const std::string& value) {
418
-
413
+ std::string t_go_generator::camelcase (const std::string& value) const {
419
414
std::string value2 (value);
420
415
std::setlocale (LC_ALL, " C" ); // set locale to classic
421
416
@@ -436,7 +431,7 @@ std::string t_go_generator::camelcase(const std::string& value) {
436
431
return value2;
437
432
}
438
433
439
- std::string t_go_generator::publicize (const std::string& value, bool is_args_or_result) {
434
+ std::string t_go_generator::publicize (const std::string& value, bool is_args_or_result) const {
440
435
if (value.size () <= 0 ) {
441
436
return value;
442
437
}
@@ -479,7 +474,7 @@ std::string t_go_generator::publicize(const std::string& value, bool is_args_or_
479
474
return prefix + value2;
480
475
}
481
476
482
- std::string t_go_generator::new_prefix (const std::string& value) {
477
+ std::string t_go_generator::new_prefix (const std::string& value) const {
483
478
if (value.size () <= 0 ) {
484
479
return value;
485
480
}
@@ -491,7 +486,7 @@ std::string t_go_generator::new_prefix(const std::string& value) {
491
486
return " New" + publicize (value);
492
487
}
493
488
494
- std::string t_go_generator::privatize (const std::string& value) {
489
+ std::string t_go_generator::privatize (const std::string& value) const {
495
490
if (value.size () <= 0 ) {
496
491
return value;
497
492
}
@@ -639,6 +634,43 @@ void t_go_generator::init_generator() {
639
634
string target = module;
640
635
package_dir_ = get_out_dir ();
641
636
637
+ // This set is taken from https://github.com/golang/lint/blob/master/lint.go#L692
638
+ commonInitialisms.insert (" API" );
639
+ commonInitialisms.insert (" ASCII" );
640
+ commonInitialisms.insert (" CPU" );
641
+ commonInitialisms.insert (" CSS" );
642
+ commonInitialisms.insert (" DNS" );
643
+ commonInitialisms.insert (" EOF" );
644
+ commonInitialisms.insert (" GUID" );
645
+ commonInitialisms.insert (" HTML" );
646
+ commonInitialisms.insert (" HTTP" );
647
+ commonInitialisms.insert (" HTTPS" );
648
+ commonInitialisms.insert (" ID" );
649
+ commonInitialisms.insert (" IP" );
650
+ commonInitialisms.insert (" JSON" );
651
+ commonInitialisms.insert (" LHS" );
652
+ commonInitialisms.insert (" QPS" );
653
+ commonInitialisms.insert (" RAM" );
654
+ commonInitialisms.insert (" RHS" );
655
+ commonInitialisms.insert (" RPC" );
656
+ commonInitialisms.insert (" SLA" );
657
+ commonInitialisms.insert (" SMTP" );
658
+ commonInitialisms.insert (" SSH" );
659
+ commonInitialisms.insert (" TCP" );
660
+ commonInitialisms.insert (" TLS" );
661
+ commonInitialisms.insert (" TTL" );
662
+ commonInitialisms.insert (" UDP" );
663
+ commonInitialisms.insert (" UI" );
664
+ commonInitialisms.insert (" UID" );
665
+ commonInitialisms.insert (" UUID" );
666
+ commonInitialisms.insert (" URI" );
667
+ commonInitialisms.insert (" URL" );
668
+ commonInitialisms.insert (" UTF8" );
669
+ commonInitialisms.insert (" VM" );
670
+ commonInitialisms.insert (" XML" );
671
+ commonInitialisms.insert (" XSRF" );
672
+ commonInitialisms.insert (" XSS" );
673
+
642
674
while (true ) {
643
675
// TODO: Do better error checking here.
644
676
MKDIR (package_dir_.c_str ());
0 commit comments