From 2fba8f897f0a00780479c3a885a3776764739066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20W=C3=BCrbach?= Date: Thu, 20 Oct 2022 21:31:18 +0200 Subject: [PATCH] feat: basic float support --- patch_test.go | 3 ++- walker.go | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/patch_test.go b/patch_test.go index d95b03a..3b748c3 100644 --- a/patch_test.go +++ b/patch_test.go @@ -5,10 +5,10 @@ import ( "strconv" "strings" + "github.com/bxcodec/faker/v3" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/bxcodec/faker/v3" jsonpatch2 "github.com/evanphx/json-patch" "github.com/snorwin/jsonpatch" @@ -33,6 +33,7 @@ type B struct { Uint32 uint32 `json:"uint32"` Uint64 uint64 `json:"uint64"` UintPtr uintptr `json:"ptr" faker:"-"` + Float64 float64 `json:"float64"` } type C struct { diff --git a/walker.go b/walker.go index eb37ef7..c013a8a 100644 --- a/walker.go +++ b/walker.go @@ -60,6 +60,10 @@ func (w *walker) walk(modified, current reflect.Value, pointer JSONPointer) erro if modified.Bool() != current.Bool() { w.replace(pointer, modified.Bool(), current.Bool()) } + case reflect.Float64: + if modified.Float() != current.Float() { + w.replace(pointer, modified.Float(), current.Float()) + } case reflect.Invalid: // undefined interfaces are ignored for now return nil