Draft
Conversation
…nerated resource.Object.Copy code.
…se for GoTypes generation.
…Update test golden files with generated copy code.
IfSentient
added a commit
that referenced
this pull request
Apr 15, 2025
…#744) `resource.CopyObject` and `resource.CopyObjectInto` incorrectly zero `time.Time` values when doing their copy, as it tries to copy `time.Time` instances as structs using reflection. Since `time.Time` has no exported fields, this does not work. To fix this behavior, check if the struct to be copied is `typeOf(time.Time)`, and, if so, directly copy it with `dst.Set(src)`, rather than recursively calling `CopyObjectInto` to copy it as a user-defined struct. This does bring up the issue that any other "special" types which have custom `MarshalJSON`/`UnmarshalJSON` implementations but no exported fields will also fail with the deep copy performed by `resource.CopyObject`/`resource.CopyObjectInto`. I'm not sure if this is a restriction we want to live with, or attempt to solve here. Ultimately, a better solution would be to avoid using relfection for copying objects entirely, and rely on generated deep copy methods in objects (see #424).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft PR tracking work done a few months ago for copy codegen