You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "Sylwester Lachiewicz (Jira)" <ji...@apache.org> on 2026/09/08 11:30:00 UTC
[jira] [Resolved] (THRIFT-5801) Go does not handle the default value of list type correctly
[ https://issues.apache.org/jira/browse/THRIFT-5801?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sylwester Lachiewicz resolved THRIFT-5801.
------------------------------------------
Resolution: Not A Bug
Resolving as Not A Bug: Go and Rust omitting default collections when unset is intentional, compliant with Thrift IDL optional write semantics, and avoids transmitting default collections over the wire on every RPC call.
> Go does not handle the default value of list type correctly
> -----------------------------------------------------------
>
> Key: THRIFT-5801
> URL: https://issues.apache.org/jira/browse/THRIFT-5801
> Project: Thrift
> Issue Type: Bug
> Components: Go - Compiler
> Affects Versions: 0.19.0, 0.20.0
> Reporter: Team_RPCtester
> Priority: Major
>
> Hi,
> We discover an inconsistent behavior illustrated by the following example.
> {code:java}
> namespace go commonResourcestruct
> StructClass_0 {
> 1: optional list<string, string> f_1 = ["a", "b"],
> }
> service DataService {
> StructClass_0 Method_1(1: StructClass_0 agr_method_1)
> } {code}
> When default values are set for optional container type fields (e.g., lists, sets), these fields are not automatically initialized in Go if not explicitly set, whereas in other languages, these container type fields are automatically initialized according to the default values. For example, in the Go client side, our code are as follows:
> {code:java}
> agr_method_1_0 := commonResource.NewStructClass_0()
> fmt.Println(agr_method_1_0)
> // method_1_re_agr_method_1_0: StructClass_0({F_1:<nil>}) {code}
> In the Python client side:
> {code:java}
> agr_method_1 = StructClass_0()
> print(agr_method_1)
> # agr_method_1: StructClass_0(f_1-[’a’,’b’]) {code}
> In Go, the field f_1 is nil, while in Python, the field f_1 is automatically set to its default value ['a', 'b'].
> Can you help check the issue?
> Thank you.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)