gf
gf copied to clipboard
The fields in the structure will not be set to default values when requesting
Go version
go version go1.21.3 darwin/amd64
GoFrame version
2.7.1
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
请求 Hello 接口,没有传任何值
type HelloReq struct {
g.Meta `path:"/hello" tags:"Hello" method:"post" summary:"You first hello api"`
Data HelloOption `p:"data"`
UUID string `p:"uuid" dc:"uuid" d:"00000"`
}
type HelloOption struct {
Option1 string `p:"option_1" d:"123123"`
}
type HelloRes struct {
g.Meta `mime:"text/html" example:"string"`
}
What did you see happen?
HelloOption 结构体里面的值不会被初始化
What did you expect to see?
期望请求里面的值都会被设置成默认值
对于默认值的设置,目前没有递归的检查结构体,可以把HelloOption改成匿名的结构体试试
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
For the setting of default values, there is currently no recursive checking structure. You can try changing HelloOption to an anonymous structure.