-
Notifications
You must be signed in to change notification settings - Fork 10
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
从1.7.0开始,查询结果为空返回的是nil了? #437
Comments
查不到数据一直都是零值呢 |
代码大致是这样
代码是没任何变化的,看到报错后退回到1.6.7就正常了~~ |
打印 fmt.Printf("%#v", rows) 1.6.7是[]entity.RealDataDTO{} 应该是没有返回初始化后的空切片 |
是的,1.6.7 会在处理反射的时候会先去 make 一次, 1.6.7
1.7.0
|
那是否会修复这个问题,保持和旧版本的兼容? |
这不是 bug,而是一个意外的特性。为了保持兼容性,新版本将默认保持返回空切片的行为,但如果你希望返回 nil 切片,可以通过设置环境变量 新版本将在 go1.24 发布之后发布。 |
好的,辛苦了。 |
已经发布了 |
有类似这样的结构
Expected Result
在1.6.7及之前的版本可用正常返回给前端空数组[]
{"list":[],"count":0}
Actual Result
在1.7.0及之后的版本返回的是null
{"list":null,"count":0}
导致前端大面积报错
The text was updated successfully, but these errors were encountered: