Question about function Decode in package hex

Hi Golang!

I have two questions for following Decode function.

One question

Why do a and b need but one by one?

Other question

About L69
dst[i] = (a << 4) | b
Why does this code slide 4?
Recently, I start to read source code and it’s difficult to understand.
Please help me.
Thank you.


A hex digit represents the range 0-15 which is four bits of data. Two digits can represent eight bits, or a byte. Hence a and b, and shifting a four bits to the left.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.