// Callback function: invoked after the deletion of an object. To clear its fields func clearFields(scope *gorm.Scope) { if !scope.HasError() { scope.Value = reflect.New(reflect.TypeOf(scope.Value)) } }