[ 
https://issues.apache.org/jira/browse/THRIFT-4410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sylwester Lachiewicz resolved THRIFT-4410.
------------------------------------------
    Resolution: Not A Problem

This is by design and still so on 0.24.0. {{publicize}} in 
[t_go_generator.cc|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_go_generator.cc]
 appends an underscore to any identifier ending in Args or Result, because the 
generator creates an {{<Method>Args}} and a {{<Method>Result}} struct for every 
service method and a user type with such a name would collide. For field names 
the guard is not needed, but removing it would rename generated fields for 
every IDL that has one, so it stays until a major release. Resolving as Not A 
Problem.

_This comment was created with AI assistance._

> Extra ending underscore with field ending with `result` for Golang
> ------------------------------------------------------------------
>
>                 Key: THRIFT-4410
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4410
>             Project: Thrift
>          Issue Type: Question
>          Components: Go - Compiler
>    Affects Versions: 0.10.0
>         Environment: macos high sierra
>            Reporter: Bob Cao
>            Priority: Trivial
>
> Given a struct where fields ending with {{result}}
> {code}
> struct Test {
>     1: optional string id_result
>     2: optional string name_result
>     3: optional string full_description_result
>     4: optional string image_url_result
> }
> {code}
> The generated go codes are 
> {code:go}
> type Test struct {
>   IDResult_ *string `thrift:"id_result,1" db:"id_result" 
> json:"id_result,omitempty"`
>   NameResult_ *string `thrift:"name_result,2" db:"name_result" 
> json:"name_result,omitempty"`
>   FullDescriptionResult_ *string `thrift:"full_description_result,3" 
> db:"full_description_result" json:"full_description_result,omitempty"`
>   ImageURLResult_ *string `thrift:"image_url_result,4" db:"image_url_result" 
> json:"image_url_result,omitempty"`
> }
> {code}
> I am expecting the field has the same name as defined (no undersore at the 
> end). 
> Thanks  [~jensg] for pointing out the codes, if anyone could en-light me 
> about why IDL identifiers end with "Args"/"Result" interferes with the 
> implicit service, that will be much appreciated!!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to