-
Notifications
You must be signed in to change notification settings - Fork 54
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
Go 1.16 will change behavior of what appears to be a buggy conditional #137
Comments
This was referenced Jan 29, 2021
anitgandhi
added a commit
to digitalocean/validate
that referenced
this issue
Feb 25, 2021
… v0.19.8 As reported in go-openapi#137, changes in Go 1.16's `reflect` package cause the type validator to fail now. Incorporate a fix from go-openapi#138 to fix that. For the time being, for internal compatibility and transitive dependency issues, we need to stick with v0.19.8. But to unblock upgrading to Go 1.16.0, we need this hotfix.
tamalsaha
added a commit
to kmodules/codespan-schema-checker
that referenced
this issue
Mar 9, 2021
ref: go-openapi/validate#137 Signed-off-by: Tamal Saha <tamal@appscode.com>
tamalsaha
added a commit
to appscodelabs/k8s-gomod-refresher
that referenced
this issue
Mar 9, 2021
ref: go-openapi/validate#137 Signed-off-by: Tamal Saha <tamal@appscode.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This line of code looks buggy to me:
https://github.com/go-openapi/validate/blob/master/type.go#L140
The troublesome code is:
The function
reflect.DeepEqual
takes two different values of any type and returns whether they are "deep equal". It does not ordinarily take two different values of the typereflect.Value
, because it is not normally interesting whether two differentreflect.Value
values are equal. What is interesting is whether the values stored in thereflect.Value
values are equal.Before Go 1.16, a call to
reflect.Zero
would internally store a pointer to a newly allocated zero value. Thus before Go 1.16 this expression would always returnfalse
(at least, I can't think of any cases where it would returntrue
). In Go 1.16 that was changed by https://golang.org/cl/192331: as an optimization,reflect.Zero
will now use the same pointer for all types smaller than 1024 bytes. The effect is that now ifdata
was itself obtained by a call toreflect.Zero
, the expression will now returntrue
.It appears that the code is trying to do something like
which as of Go 1.13 is more efficiently written as
I don't know what the right fix is here. Changing this code has various knock-on effects on other packages that use this one. Is an empty string really the same as a null value? I don't know.
The text was updated successfully, but these errors were encountered: