Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The fields in the structure will not be set to default values ​​when requesting #3594

Open
xixihahag opened this issue May 21, 2024 · 2 comments
Labels
enhancement planned This issue/proposal is planned into our next steps.

Comments

@xixihahag
Copy link

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"`
}
image

What did you see happen?

HelloOption 结构体里面的值不会被初始化
image

What did you expect to see?

期望请求里面的值都会被设置成默认值

@xixihahag xixihahag added the bug It is confirmed a bug, but don't worry, we'll handle it. label May 21, 2024
@Issues-translate-bot Issues-translate-bot changed the title 请求时结构体里面的字段不会被设置为默认值 The fields in the structure will not be set to default values ​​when requesting May 21, 2024
@wln32
Copy link
Member

wln32 commented May 21, 2024

对于默认值的设置,目前没有递归的检查结构体,可以把HelloOption改成匿名的结构体试试

@Issues-translate-bot
Copy link

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.

@gqcn gqcn added enhancement planned This issue/proposal is planned into our next steps. and removed bug It is confirmed a bug, but don't worry, we'll handle it. labels May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement planned This issue/proposal is planned into our next steps.
Projects
None yet
Development

No branches or pull requests

4 participants