Panic when copying private properties.

When CopyProperties comes across private properties, it silently ignores
them. This is error-prone and can result in a bug very hard to debug if
the developer is unaware of the behavior.

Change-Id: Id6a0752e384ec7fed35728c1e87dbfa95fea84f2
This commit is contained in:
Jaewoong Jung 2019-03-07 14:01:22 -08:00
parent a9df651359
commit 7d699c37ec

View file

@ -35,8 +35,7 @@ func CopyProperties(dstValue, srcValue reflect.Value) {
for i, field := range typeFields(typ) {
if field.PkgPath != "" {
// The field is not exported so just skip it.
continue
panic(fmt.Errorf("can't copy a private field %q", field.Name))
}
srcFieldValue := srcValue.Field(i)