[ https://issues.apache.org/jira/browse/THRIFT-3051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14746146#comment-14746146 ]
Hudson commented on THRIFT-3051: -------------------------------- SUCCESS: Integrated in Thrift #1654 (See [https://builds.apache.org/job/Thrift/1654/]) THRIFT-3051 Go Thrift generator creates bad go code (jensg: rev 0f17e15255f772167ab8bd844a5ddbcbec7ea616) * compiler/cpp/src/generate/t_go_generator.cc * lib/go/test/Makefile.am * lib/go/test/UnionDefaultValueTest.thrift * lib/go/test/tests/union_default_value_test.go > Go Thrift generator creates bad go code > --------------------------------------- > > Key: THRIFT-3051 > URL: https://issues.apache.org/jira/browse/THRIFT-3051 > Project: Thrift > Issue Type: Bug > Components: Go - Compiler > Affects Versions: 0.9.2, 1.0 > Environment: Mac OS X 10.10.2 > Thrift 0.9.2 installed via homebrew, and Thrift HEAD (identifies as > 1.0.0-dev) installed via homebrew > Reporter: Silas Snider > Assignee: Jake Farrell > Fix For: 0.9.3 > > Attachments: THRIFT-3051.patch > > > h2. Motivation > I was attempting to build a go tool that used the Apache Aurora thrift > interface, only to be stymied because thrift generates invalid code for the > current api.thrift interface. (found under > api/src/main/thrift/org/apache/aurora/gen/api.thrift) > h2. Steps to replicate > # Create a thrift file called test.thrift containing the text: > {code:title=test.thrift|borderStyle=solid} > struct Option1 { > } > struct Option2 { > 1: optional string name > } > union Descendant { > 1: Option1 option1 > 2: Option2 option2 > } > struct TestStruct { > 1: optional Descendant descendant = { "option1": {}} > } > {code} > # Run {{thrift -o somedir -r --gen go test.thrift}} > h2. Expected Result > The command indicates success, and the {{somedir}} directory contains a tree > of go code that successfully compiles. > h2. Actual Result > The above command outputs > {code} > /somedir/gen-go//test/ttypes.go:317:6: expected '}', found ':=' > /somedir/gen-go//test/ttypes.go:318:3: expected declaration, found 'IDENT' > descendant > WARNING - Running 'gofmt -w /somedir/gen-go//test/ttypes.go' failed. > {code} > The code fails to compile with similar errors. On inspection, it appears that > the go compiler outputs > {code:title=ttypes.go|borderStyle=solid} > var TestStruct_Descendant_DEFAULT *Descendant = &Descendant{ > v1 := &Option1{} > descendant.Option1 = v1} > {code} > which is entirely incorrect. This code should instead be > {code:title=ttypes.go|borderStyle=solid} > var TestStruct_Descendant_DEFAULT *Descendant = &Descendant{ > Option1: &Option1{}} > {code} > When this change is made, the compilation succeeds. -- This message was sent by Atlassian JIRA (v6.3.4#6332)