fmt.Println(hex.Dump([]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0}))
It shows:
00000000 01 02 03 04 05 06 07 08 09 00 01 02 03 04 05 06 |................|
00000010 07 08 09 00 |....|
How to add an indent before the hex addresses to all lines? like
00000000 01 02 03 04 05 06 07 08 09 00 01 02 03 04 05 06 |................|
00000010 07 08 09 00 |....|
Split the lines by \n then put an indent before each line will do, but is there any built-in tool does this? I tried hex.Dumper
and tabwriter.NewWriter
, but they just treat the indent as normal data and printed along with the hex dump.
bytes.Split
andbytes.Join
.