// Create a 3-way merge patch based-on JSON merge patch. // Calculate addition-and-change patch between current and modified. // Calculate deletion patch between original and modified. func CreateThreeWayJSONMergePatch(original, modified, current []byte, fns ...mergepatch.PreconditionFunc) ([]byte, error) { … } // keepOrDeleteNullInJsonPatch takes a json-encoded byte array and a boolean. // It returns a filtered object and its corresponding json-encoded byte array. // It is a wrapper of func keepOrDeleteNullInObj func keepOrDeleteNullInJsonPatch(patch []byte, keepNull bool) ([]byte, map[string]interface{ … } // keepOrDeleteNullInObj will keep only the null value and delete all the others, // if keepNull is true. Otherwise, it will delete all the null value and keep the others. func keepOrDeleteNullInObj(m map[string]interface{ … } func meetPreconditions(patchObj map[string]interface{ … }