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

V0.7.0 递归结构体无法退出遍历 #1015

Closed
dorlolo opened this issue Dec 5, 2023 · 3 comments
Closed

V0.7.0 递归结构体无法退出遍历 #1015

dorlolo opened this issue Dec 5, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@dorlolo
Copy link

dorlolo commented Dec 5, 2023

Describe the bug
递归结构体作为请求参数时,在v0.7.0版本中没做优化,他会导致无法停止遍历

To Reproduce
举个例子

type AppMenu struct {
    Parent     *AppMenu
    Children   []AppMenu
}
func (m *menuApi) CreateMenus(ctx context.Context, c *app.RequestContext) {
	var info AppMenu
	if err := c.Bind(&info); err != nil {
		server.ReplyWithFailed(e.ArgumentParseFailed, err, c)
		return
	}
	fmt.Println(info )
}

它会一直遍历Parent字段

微信图片_20231205185227

Hertz version:

v0.7.0

@FGYFFFF
Copy link
Contributor

FGYFFFF commented Dec 5, 2023

我来修复下

@li-jin-gou li-jin-gou added the bug Something isn't working label Dec 5, 2023
@FGYFFFF
Copy link
Contributor

FGYFFFF commented Dec 5, 2023

@dorlolo 感谢反馈,之前漏掉了文中的 case。目前 #1016 已修复。如果你是json body的话,可以先使用 BindJSON,规避这个问题

@dorlolo
Copy link
Author

dorlolo commented Dec 5, 2023

@FGYFFFF 好的!

@dorlolo dorlolo closed this as completed Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

3 participants