Open ksw2000 opened 4 hours ago
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord
@ksw2000 Hi, are you sure SetValWithStruct()
should also skip the 0's in the int slice, I don't think [1,2]
and [0,1,2]
are the same slice.
@JIeJaitt I'm not entirely sure, since there are two different logics for processing int slice and bool slice in the SetValWithStruct()
function. In my opinion, there are absolutely bugs.
If the 0
in [0, 1, 2]
should be stored. I think false
in [true, false]
should be stored too.
That is to say, the expected behavior is changed to:
1
0, 1, 2,
true, false,
SetValWithStruct
does not consider zero values when processing slices. However, since it only stores true when processing bool slices, zero values are considered in bool slices.
@ksw2000 I think what you said makes sense. There is indeed a problem here, which creates ambiguity for users. I think if possible, two functions are provided here. One is the normal SetValWithStruct()
function that will store 0
and false
, and the other is the SetValWithStructSpecial()
function that will skip 0
and false
values.
Bug Description
The function
SetValWithStruct()
sets values using structs. It skips zero values, such as0
andfalse
. However, if the fields are slices (excluding bool slices), all the values in the slices will be set.How to Reproduce
To reproduce the bugs, we can simply add a test in
client/request_test.go
:result:
Expected Behavior
The
SetValWithStruct()
should skip0
in the int slice too.Fiber Version
latest
Code Snippet (optional)
No response
Checklist: