From 6e98ac91005a232ef5c6450f163ce5585a7ffb5d Mon Sep 17 00:00:00 2001 From: bryanqiu Date: Mon, 30 Jan 2023 09:33:07 +0800 Subject: [PATCH] add FixToNo0x --- str.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/str.go b/str.go index a5a84a6..e0c8431 100644 --- a/str.go +++ b/str.go @@ -126,3 +126,11 @@ func GetEnvDefault(key, defval string) string { return defval } } + +// fix hex string to no 0x prefix +func FixToNo0x(hexstr string) string { + if strings.HasPrefix(hexstr, "0x") { + return hexstr[2:] + } + return hexstr +}