3. Numbers

When I first learned C, the compiler supported 16-bit ints and 32-bit longs. A few years later, it became more common for int to be 32 bits. A lot of code was written with assumptions about the sizes of C types, and this caused people a lot of problems when 64-bit systems became common.

The C99 standard introduced the stdint.h header, which defined types like uint32_t, an unsigned integer that was 32 bits on any platform. This helped a bit, but on some platforms a cast between a uint32_t and an unsigned int was safe and wouldn’t generate a warning, since they were the same underlying type, while on others it was not.

Go learned from this mess and provides explicitly sized integer and floating-point types from the start. A uint64 is ...

Get The Go Programming Language Phrasebook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.