[ https://issues.apache.org/jira/browse/THRIFT-4254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16095887#comment-16095887 ]
Davin Chia commented on THRIFT-4254: ------------------------------------ Seems to be solved in current version. Closing for now. > Go generator does not respect typedef types when generating read/write > functions. > --------------------------------------------------------------------------------- > > Key: THRIFT-4254 > URL: https://issues.apache.org/jira/browse/THRIFT-4254 > Project: Thrift > Issue Type: Bug > Components: Go - Compiler > Affects Versions: 0.10.0 > Reporter: Davin Chia > > Give the following thrift definitions: > > {code:java} > typedef i64 RequestId > struct Custom { > optional set<RequestId> field_a; > } > {code} > The following go code is generated: > {code:java} > type RequestId int64 > type Custom struct { > FieldA map[RequestId]struct{} > } > ... > func (p *Custom) ReadField1(iprot thrift.TProtocol) error { > _, size, err := iprot.ReadSetBegin() > if err != nil { > return thrift.PrependError("error reading set begin: ", err) > } > tSet := make(map[int64]struct{}, size) > p.ActiveImportIds = tSet > for i := 0; i < size; i ++ { > var _elem1 int64 > if v, err := iprot.ReadI64(); err != nil { > return thrift.PrependError("error reading field 0: ", err) > } else { > _elem1 = v > } > p.FieldA[_elem1] = struct{}{} > } > if err := iprot.ReadSetEnd(); err != nil { > return thrift.PrependError("error reading set end: ", err) > } > return nil > } > {code} > There are two errors here: > 1. {code:java}tSet{code} should be {code:java} map[RequestId]struct{} {code} > and not {code:java}map[int64]struct{}{code}. > 2. {code:java} elem_1 {code}should be of type {code:java}RequestId{code} and > the values need to be case to {code:java}RequestId{code} before assigning to > {code:java}elem_1{code}. -- This message was sent by Atlassian JIRA (v6.4.14#64029)