Byte
The byte
type in Go is just an alias for uint8
, which is a number that has 8 bits of storage. In reality, byte
is a significant type, and you'll see it in lots of places. A bit is a single binary value, a single on/off switch. Grouping bits into groups of 8 was a common standard in early computing and became a near-universal way to encode data. 8 bits have 256 possible combinations of "off" and "on," uint8
has 256 possible integer values from 0 to 255. All combinations of on and off can are represented with this type.
You'll see byte
used when reading and writing data to and from a network connection and when reading and writing data to files.
With this, we're all done with numbers. Now, let's look at how Go stores and manages text.