[ https://issues.apache.org/jira/browse/THRIFT-5461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17412235#comment-17412235 ]
Yuri Melnikov commented on THRIFT-5461: --------------------------------------- [~fishywang] My issue is a bit different. A default value type {{set<binary>}} is translated to the Go type {{[][]byte}}, but its assigned value is translated to {{[]string{}}}, which is an incompatible type. Please check the PR above. The unit-test is passing after the fix: {code} root@2dda16a0c248:/thrift/src# make -Ctest/go check make: Entering directory '/thrift/src/test/go' Makefile:657: warning: overriding recipe for target 'check' Makefile:506: warning: ignoring old recipe for target 'check' grep -v list.*map.*list.*map ../../test/ThriftTest.thrift > ThriftTest.thrift mkdir -p src/gen /thrift/src/compiler/cpp/thrift -out src/gen --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/test/go/src/gen/ ThriftTest.thrift [WARNING:/thrift/src/test/go/ThriftTest.thrift:43] No generator named 'noexist' could be found! [WARNING:/thrift/src/test/go/ThriftTest.thrift:45] cpp generator does not accept 'noexist' as sub-namespace! /thrift/src/compiler/cpp/thrift -out src/gen --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/test/go/src/gen/ ../StressTest.thrift [WARNING:/thrift/src/test/StressTest.thrift:31] Consider using the more efficient "binary" type instead of "list<byte>". [WARNING:/thrift/src/test/StressTest.thrift:31] Consider using the more efficient "binary" type instead of "list<byte>". touch gopath sh genmock.sh go: downloading github.com/golang/mock v1.5.0 go: downloading golang.org/x/mod v0.3.0 go: downloading golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e go: downloading golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 /usr/local/bin/go test -mod=mod -v ./src/common/... go: downloading github.com/golang/mock v1.5.0 === RUN TestAllConnection --- PASS: TestAllConnection (0.02s) === RUN TestHttpContextTimeout --- PASS: TestHttpContextTimeout (0.05s) PASS ok github.com/apache/thrift/test/go/src/common 0.076s make: Leaving directory '/thrift/src/test/go' {code} > Invalid golang code generated for optional set<binary> with a default value > --------------------------------------------------------------------------- > > Key: THRIFT-5461 > URL: https://issues.apache.org/jira/browse/THRIFT-5461 > Project: Thrift > Issue Type: Bug > Components: Go - Compiler > Affects Versions: 0.15.0, 0.14.2 > Reporter: Yuri Melnikov > Priority: Major > Original Estimate: 24h > Remaining Estimate: 24h > > There's a bug in the Thrift Go generator that happens when an optional > set<bynary> is used with a default value. For example, a simple struct like > this: > {code:java} > struct OptionalSetBinary { > 1: optional set<binary> bin = {} > } > {code} > ...generates a default value like this: > {code:go} > var OptionalSetBinary_Bin_DEFAULT [][]byte = []string{ > } > {code} > ...and fails the compilation of the unit-test: > {code:java} > ../src/gen/thrifttest/ThriftTest.go:5620:5: cannot use []string{} (type > []string) as type [][]byte in assignment > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)