From 7330c97b5b00255db9dc1ffaff942992f80fb7d1 Mon Sep 17 00:00:00 2001 From: Maran Date: Mon, 16 Mar 2015 15:17:19 +0100 Subject: DRY up the use of toHex in the project and move it to common --- common/common.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common') diff --git a/common/common.go b/common/common.go index 1371d18d4..155bb5c2a 100644 --- a/common/common.go +++ b/common/common.go @@ -65,6 +65,15 @@ func DefaultDataDir() string { } } +func ToHex(b []byte) string { + hex := Bytes2Hex(b) + // Prefer output of "0x0" instead of "0x" + if len(hex) == 0 { + hex = "0" + } + return "0x" + hex +} + func FromHex(s string) []byte { if len(s) > 1 { if s[0:2] == "0x" { -- cgit v1.2.3