jinzhu / copier

Copier for golang, copy value from struct to struct and more
MIT License
5.58k stars 489 forks source link

fix json error when struct field is slice and is nil #142

Open hemanth132 opened 2 years ago

hemanth132 commented 2 years ago

When using copier for a struct with a nil byte slice as a field to a target struct which contains a similar nil byte slice field, the target slice field is being set with an empty slice instead of nil.

This cause issues, when the resulting target slice is converted to json using json.Marsha() method. Added a testcase for the same.