refactor: update go mod library (#210)

refactor: update go mod library and refactor dev logic

Co-authored-by: wencaiwulue <895703375@qq.com>
This commit is contained in:
naison
2024-04-04 12:04:02 +08:00
committed by GitHub
parent 91b3a2fbdf
commit 87166494c0
1336 changed files with 51428 additions and 57404 deletions

View File

@@ -27,7 +27,7 @@ func (j *JsonPatchOperation) MarshalJSON() ([]byte, error) {
b.WriteString(fmt.Sprintf(`"op":"%s"`, j.Operation))
b.WriteString(fmt.Sprintf(`,"path":"%s"`, j.Path))
// Consider omitting Value for non-nullable operations.
if j.Value != nil || j.Operation == "replace" || j.Operation == "add" {
if j.Value != nil || j.Operation == "replace" || j.Operation == "add" || j.Operation == "test" {
v, err := json.Marshal(j.Value)
if err != nil {
return nil, err
@@ -234,7 +234,11 @@ func compareArray(av, bv []interface{}, p string) []JsonPatchOperation {
processArray(av, bv, func(i int, value interface{}) {
retval = append(retval, NewPatch("remove", makePath(p, i), nil))
})
reversed := make([]JsonPatchOperation, len(retval))
for i := 0; i < len(retval); i++ {
reversed[len(retval)-1-i] = retval[i]
}
retval = reversed
// Find elements that need to be added.
// NOTE we pass in `bv` then `av` so that processArray can find the missing elements.
processArray(bv, av, func(i int, value interface{}) {