slachiewicz opened a new pull request, #3823:
URL: https://github.com/apache/thrift/pull/3823
Client: go
### Problem
When an enum field held an out-of-range integer value, Go's generated
`String()` method returned `"<UNSET>"`, misleading loggers, debug printers, and
validators into treating the field as unset even though the wire protocol
preserved the raw integer and transmitted it correctly. In contrast, Rust
(`Enum0(10)`), C++ (`10`), Python (`10`), and Node.js (`10`) preserve or format
the integer value.
### Changes
1. In `t_go_generator.cc`, updated `Enum.String()` to return
`fmt.Sprintf("%s(%d)", tenum_name, p)` for undefined values, matching idiomatic
Go `stringer` conventions.
2. Generated `(p Enum) IsDefined() bool` method on all enums.
3. Updated `go_validator_generator.cc` to use `!tgt.IsDefined()` instead of
`tgt.String() == "<UNSET>"`.
4. Added unit regression tests in `lib/go/test/tests/enum_values_test.go`.
Co-Authored-By: Antigravity 2.0 <[email protected]>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]