You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem appears to be that when proto.Equal uses reflection to recursively extract all struct fields, it doesn't stop recursing when it reaches the time.Time field. That struct has unexported fields, in particular a string, which reflect.Value.Interface() refuses to give to us. I think this could be avoided by checking if a value we're looking at has StdTime and doing something smarter in that case.
#682 incidentally fixes this, because it avoids reflect.Value.Interface() in favor of using reflect.Value.String() to compare strings. That seems like a reasonable thing to do, and fixes my particular use case (using proto.Equal to compare messages in unit tests), but may not be the best way to compare timestamps in general.
The text was updated successfully, but these errors were encountered:
I think this should work, but it panics (go 1.14).
The problem appears to be that when
proto.Equal
uses reflection to recursively extract all struct fields, it doesn't stop recursing when it reaches thetime.Time
field. That struct has unexported fields, in particular a string, whichreflect.Value.Interface()
refuses to give to us. I think this could be avoided by checking if a value we're looking at has StdTime and doing something smarter in that case.#682 incidentally fixes this, because it avoids
reflect.Value.Interface()
in favor of usingreflect.Value.String()
to compare strings. That seems like a reasonable thing to do, and fixes my particular use case (usingproto.Equal
to compare messages in unit tests), but may not be the best way to compare timestamps in general.The text was updated successfully, but these errors were encountered: