code: func mergeSliceWithSpecialElements(original, patch []interface{}, mergeKey string) ([]interface{}, []interface{}, error) {
  	patchWithoutSpecialElements := []interface{}{}
  	replace := false
  	for _, v := range patch {
  		typedV := v.(map[string]interface{})
  		patchType, ok := typedV[directiveMarker]
  		if !ok {
  			patchWithoutSpecialElements = append(patchWithoutSpecialElements, v)
  		} else {
  			switch patchType {
  			case deleteDirective:
  				mergeValue, ok := typedV[mergeKey]
  				if ok {
  					var err error
  					original, err = deleteMatchingEntries(original, mergeKey, mergeValue)
  					if err != nil {
  						return nil, nil, err
  					}
  				} else {
  					return nil, nil, mergepatch.ErrNoMergeKey(typedV, mergeKey)
  				}
  			case replaceDirective:
  				replace = true
  				// Continue iterating through the array to prune any other $patch elements.
  			case mergeDirective:
  				return nil, nil, fmt.Errorf("merging lists cannot yet be specified in the patch")
  			default:
  				return nil, nil, mergepatch.ErrBadPatchType(patchType, typedV)
  			}
  		}
  	}
  	if replace {
  		return patchWithoutSpecialElements, nil, nil
  	}
  	return original, patchWithoutSpecialElements, nil
  }
docs: // mergeSliceWithSpecialElements handles special elements with directiveMarker
  // before merging the slices. It returns a updated `original` and a patch without special elements.
  // original and patch must be slices of maps, they should be checked before calling this function.