From f51c8db16dd26b5691ffb4b154041fd3a816f157 Mon Sep 17 00:00:00 2001 From: zemyblue Date: Fri, 8 May 2020 20:10:29 +0900 Subject: [PATCH] Remove unused RemoveProperty of unmarshal.go --- cmd/contract_tests/main.go | 2 +- cmd/contract_tests/unmarshaler/unmarshal.go | 24 --------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/cmd/contract_tests/main.go b/cmd/contract_tests/main.go index 1d067b573..727828ce7 100644 --- a/cmd/contract_tests/main.go +++ b/cmd/contract_tests/main.go @@ -67,7 +67,7 @@ func main() { func removeOptionalFieldsOfExpected(t *transaction.Transaction, paths []string) { expected := unmarshaler.UnmarshalJSON(&t.Expected.Body) for _, path := range paths { - expected.RemoveProperty(strings.Split(path, ".")) + expected.DeleteProperty(strings.Split(path, ".")...) } newBody, err := json.Marshal(expected.Body) if err != nil { diff --git a/cmd/contract_tests/unmarshaler/unmarshal.go b/cmd/contract_tests/unmarshaler/unmarshal.go index 440a13a80..d336c9009 100644 --- a/cmd/contract_tests/unmarshaler/unmarshal.go +++ b/cmd/contract_tests/unmarshaler/unmarshal.go @@ -2,9 +2,6 @@ package unmarshaler import ( "encoding/json" - "fmt" - "strconv" - "gopkg.in/yaml.v3" ) @@ -42,27 +39,6 @@ func (obj *UnmarshalledArbitraryObject) DeleteProperty(keys ...string) { delete(body.(map[string]interface{}), lastKey) } -func (obj *UnmarshalledArbitraryObject) RemoveProperty(keys []string) { - keyToRemove := keys[len(keys)-1] - - body := obj.Body - for _, key := range keys[:len(keys)-1] { - switch parent := body.(type) { - case map[string]interface{}: - body = parent[key] - case []interface{}: - idx, err := strconv.Atoi(key) - if err != nil { - panic(fmt.Sprintf("illegal property path(%s)", err)) - } - body = parent[idx] - default: - panic("illegal property path") - } - } - delete(body.(map[string]interface{}), keyToRemove) -} - func UnmarshalJSON(str *string) UnmarshalledArbitraryObject { return UnmarshalledArbitraryObject{unmarshalArbitraryFormat(json.Unmarshal, str)} }