copier icon indicating copy to clipboard operation
copier copied to clipboard

Fixed issue with nested pointer structs

Open NicklasWallgren opened this issue 2 years ago • 0 comments

Fixes https://github.com/jinzhu/copier/issues/99

An alternative to using defer/recover is to utilize the FieldByIndexErr, but it's only available in 1.18+

structField, ok := source.Type().FieldByName(fieldName)
if !ok {
	return reflect.Value{}
}

field, err := source.FieldByIndexErr(structField.Index)
if err != nil {
	return reflect.Value{}
}

return field

NicklasWallgren avatar Jul 02 '22 12:07 NicklasWallgren