-
Notifications
You must be signed in to change notification settings - Fork 210
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
out-of-the-box support for atomic.Pointer #326
Comments
At present, Regarding the inability to properly write a transformer for this, I've stated in #310 (comment) that the inability of |
Both of these other alternatives sound better to me, in particular adding Let's keep this issue open until some solution is implemented? But up to you... |
After thinking about Also, if |
You could imagine the following being added: package atomic
func (x *Int64) Equal(y *Int64) bool { return x.Load() == y.Load() }
func (x *Int64) String() string { return fmt.Sprint(x.Load()) } |
I suspect |
Also, |
In the case of Regardless of what we do here, the general philosophy of Of course, this still requires #310 be addressed, which is a prerequisite. |
Doesn't But that's just my two cents. Addressing #310 is the more general solution. |
Perhaps, but I still stand by "the general philosophy of cmp is to not have specialized behavior of types". |
introduced in a851e39 This is pretty sketchy but there doesn't seem to be a nice way to do this, there's an open issue for this issue right now. google/go-cmp#326
Suppose a struct contains an atomic.Pointer instead of a normal pointer:
Using
cmp.Diff
for such struct instances fails because thePointer
type contains unexported fields:See https://go.dev/play/p/Jp91WpSKFRx for a full example.
It would be nice if
cmp.Diff
automatically did the same thing foratomic.Pointer
as it does for normal pointers: compare the value that is being pointed to.The argument for such special support is two-fold:
atomic.Pointer
is impossible without copying that value, which correctly fails the "go vet"copylocks
check. See https://github.com/kubernetes/kubernetes/pull/115777/files#diff-9b169e646cb953f34c0362a885d844daea86f5bef52012cb3af974f176bb281f and take address of field for comparison #310 (comment).The text was updated successfully, but these errors were encountered: