-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
util/gconv: compatibility for bool pointer #3764
Comments
@qinyuguang 老版本的代码在没有改造前,对于 bool 类型的转换是以下流程 新版本的改造代码直接走了gconv.Bool函数的逻辑,里面对于指针的处理是以下流程 gconv.Bool函数的实现----只要指针非nil,就全部为true,这个逻辑理论上是错误的, 可能会导致以下情况 var f = new(bool) // f = &false 实际
var v= gconv.Bool(f)
fmt.Println(v)
// output: true |
@qinyuguang Before the old version of the code was modified, the conversion process for bool type was as follows The new version of the modified code directly uses the logic of the gconv.Bool function. The processing of pointers is as follows: Code to register bool conversion function The implementation of the gconv.Bool function - as long as the pointer is non-nil, all are true. This logic is theoretically wrong. This may lead to the following situations var f = new(bool) // f = &false actual
var v= gconv.Bool(f)
fmt.Println(v)
// output: true |
What do you want to ask?
Code
v2.7.2 output
v2.7.3 output
Question
Need maintain compatibility when upgrading minor versions?
The text was updated successfully, but these errors were encountered: