-
Couldn't load subscription status.
- Fork 18.4k
Open
Description
What does it do
Use (*json.Encoder).SetZeroizeNilSlice(true) can let the encoder encode nil slice as an empty json array [] instead of null
Why
If we have a nil slive []Type(nil), the encoder will encode it as null. Then the consumers will having trouble with it, they must to check if the field is null first.
A way to solve this problem is always alloc a zero length slice before encoding. However, I want my code be simplify but not fill with make([]Type, 0) every where.
Additional Information
- This change should be completely backward compatible.
- The options name is not good, maybe have to decide a better name later.
xiaokentrl and ToadKingmdlayher and vadyus
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Incoming