After upgrading the version from 0.6.2 to 0.7.2, I have encountered issues related to the handling of the 'default' tag within the BindAndValidate function. In particular, it seems that when both a 'default' and a 'json' tag are specified for a field, the decoder will always use the default value.
call hertz server with curl -X POST 'http://127.0.0.1:8888/users' --header 'Content-Type: application/json;charset=UTF-8' -d '{"page_size": 11,"page": 2}'
response body is {"page":2,"pageSize":11}
go get github.com/cloudwego/hertz@v0.7.2
repeat steps 2、3
response body is {"page":1,"pageSize":10}
if we remove "default" in go tag, there will be no issues.
Describe the bug
After upgrading the version from 0.6.2 to 0.7.2, I have encountered issues related to the handling of the 'default' tag within the BindAndValidate function. In particular, it seems that when both a 'default' and a 'json' tag are specified for a field, the decoder will always use the default value.
To Reproduce
Steps to reproduce the behavior:
go get github.com/cloudwego/hertz@v0.6.2
curl -X POST 'http://127.0.0.1:8888/users' --header 'Content-Type: application/json;charset=UTF-8' -d '{"page_size": 11,"page": 2}'
{"page":2,"pageSize":11}
go get github.com/cloudwego/hertz@v0.7.2
{"page":1,"pageSize":10}
Expected behavior
same output with 0.6.2
Hertz version:
0.7.2
Environment:
GOVERSION='go1.22.2'