copier
copier copied to clipboard
Unexported fields behaviour
Does the copier tag applied to unexported fields
I saw that an issue have been resolved for unexported fields (#111).
But I'm surprised that unexported fields are copied in the case copier tag is set to -
.
See an exemple here: https://go.dev/play/p/oW9t1vJVPX-
private tag will be ignore
func deepFields(reflectType reflect.Type) []reflect.StructField {
if reflectType, _ = indirectType(reflectType); reflectType.Kind() == reflect.Struct {
fields := make([]reflect.StructField, 0, reflectType.NumField())
for i := 0; i < reflectType.NumField(); i++ {
v := reflectType.Field(i)
// PkgPath is the package path that qualifies a lower case (unexported)
// field name. It is empty for upper case (exported) field names.
// See https://golang.org/ref/spec#Uniqueness_of_identifiers
//if v.PkgPath == "" {
fields = append(fields, v)
if v.Anonymous {
// also consider fields of anonymous fields as fields of the root
fields = append(fields, deepFields(v.Type)...)
}
//}
}
return fields
}
return nil
}
Hi,
@lixiandea , I'm not sure to understand the reason of your message. I'm showing that private tags are not ignored. My question is about the expected behaviour.
@jinzhu I still have the issue with v0.4.0. Why did you choose to copy the private fields?