View byte arrays as hex in the debugger


I am doing work with hashes, which are either [32]byte or []byte types.  I would really like to look at them as hex binary, either like

8d2d59578202c9bcda5ec9c9bcfd175381981781e50e5093cec085f7e721452d or

8d 2d 59 57 82 02 c9 bc da 5e c9 c9 bc fd 17 53 81 98 17 81 e5 0e 50 93 ce c0 85 f7 e7 21 45 2d

in the View of the array or slice, or directly in the debugger.  But what I get is more like:



0 = {uint8} 27

1 = {uint8} 230

2 = {uint8} 6

3 = {uint8} 117


Which seriously isn't any value at all in the first case unless the []byte really holds a string.  Which often just isn't the case. And in the second case I want to see hex, and not in a long drawn out list.



You can set Hex format by default in the settings: Preferences / Settings | Build, Execution, Deployment | Debugger | Data Views | Go.

Does it help? Please, provide an example with your slice of bytes and the actual result. I'll take a look.


Daniil it does help a bit (to compare visually), BUT doesn't solve that "copy value"/edit value copies bits directly and since binary formats contain lots of 0x00 and other non-printable bytes it's not that easy to paste them.


oleksandr, Could you please elaborate a bit on how Copy/Edit Value should work in the following case? Does option Hex + Decimal would solve the problem (GO-11059)?


Thanks for the prompt reply!

1) I expect copying byte array/slice of length 6 to copy string like "FF003D5DEE55", "0xFF003D5DEE55", "0xFF,0x00,0x3D,0x5D,0xEE,0x55" - any of these is OK. Critical part is to be able to copy entire array (or first 1000 (?) bytes, if too large for system clipboard)

2) Similarly, if I could switch the "View" window between "string" and Hex, and/or preview arrays in Watch/Local variables as hex strings and not byte-by-byte, that would be totally great. Again, the critical part is that I can view data from multiple arrays at once in a more compact view to be able to quickly visually compare them.

Hex+decimal is 100% unrelated. Mutating arrays could be omitted (I realize it's probably much more complicated to implement)


Thanks for the details. Feel free to follow GO-7234 & GO-6000 + GO-8561 for better visibility of hex values. I think it should cover both cases.


Yeah GO-7234 and GO-6000 will do it for Goland. Can't find similar for Uint8Array/Buffer/ArrayBuffer in WebStorm issues though, any suggestions? It's a language-neutral feature imho

(one can kinda solve it in node by making default toString return hex, but this wreaks havoc in places expecting buffer.toString() to be utf8)


As far as I know, WebStorm doesn't support displaying hex values, please see WEB-13942.


Thanks, commented there about arrays as well.


Please sign in to leave a comment.