From c4f607e236ab3f4d8c7dafa32ab43a620e5a7453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BA=E9=92=A7=E5=A8=81?= Date: Tue, 19 Feb 2019 11:28:06 +0800 Subject: [PATCH 1/2] fix optional from property in ethrpc.T --- types.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/types.go b/types.go index b90baee..201016e 100644 --- a/types.go +++ b/types.go @@ -41,9 +41,10 @@ type T struct { // MarshalJSON implements the json.Unmarshaler interface. func (t T) MarshalJSON() ([]byte, error) { - params := map[string]interface{}{ - "from": t.From, - } + params := map[string]interface{}{} + if t.From != "" { + params["from"] = t.From + } if t.To != "" { params["to"] = t.To } From f751a5eade2bea45e36fc57f914c94367307a1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BA=E9=92=A7=E5=A8=81?= Date: Tue, 19 Feb 2019 11:33:14 +0800 Subject: [PATCH 2/2] fix code format --- types.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types.go b/types.go index 201016e..b5a23f0 100644 --- a/types.go +++ b/types.go @@ -42,9 +42,9 @@ type T struct { // MarshalJSON implements the json.Unmarshaler interface. func (t T) MarshalJSON() ([]byte, error) { params := map[string]interface{}{} - if t.From != "" { - params["from"] = t.From - } + if t.From != "" { + params["from"] = t.From + } if t.To != "" { params["to"] = t.To }