From 1ba22d6fb640d481acd7e31fa6b34621ed91a573 Mon Sep 17 00:00:00 2001 From: Sean Zheng Date: Wed, 22 Nov 2023 22:04:17 +0800 Subject: [PATCH] refactor: refactor String method in Bytes type - Remove unnecessary if statement in the String method of the Bytes type Signed-off-by: Sean Zheng --- pkg/types/bytes.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/types/bytes.go b/pkg/types/bytes.go index ede540c..8acd0ac 100644 --- a/pkg/types/bytes.go +++ b/pkg/types/bytes.go @@ -12,6 +12,10 @@ type Bytes []byte // String Converts to hex string func (b Bytes) String() string { + if len(b) == 0 { + return "" + } + return fmt.Sprintf("0x%s", hex.EncodeToString(b)) }