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.
We have been using an old version of this package, and our attempts to update it to a newer version have failed because when copying a struct value to an empty interface with a nil value, a panic is caused.
In copier.go#150,
reflect.TypeOf(to.Interface())
returns nil because it's an empty interface, and when it passes that nil value intofunc indirectType
, it attempts to call theKind()
method on the nil value, causing the panic.The change I'm proposing is that in the case of the
from
value being a struct and theto
value being an empty interface, to simply callto.Set(from)
and then return.I'm fairly confident this won't break any existing client code since the current behavior in this case is to panic. But I'm very open to suggestions on how this might better be accomplished, especially in the case of
from
types other than structs, or how to best honor things like theOptions.DeepCopy
value.