Data Types in Go
Go defines four built-in data types:
- Numbers – Includes integers, floating point, and complex types
- String – A sequence of bytes; strings are immutable
- Boolean – Holds a value of either
trueorfalse - Derived Types – Includes pointer types, array types, structure types, union types, function types, slice types, interface types, map types, and channel types
Numeric Data Types
| Data Type | Range / Description |
|---|---|
| uint8 or byte | 0 to 255 |
| uint16 | 0 to 65,535 |
| uint32 | 0 to 4,294,967,295 |
| uint64 | 0 to 18,446,744,073,709,551,615 |
| int8 | -128 to 127 |
| int16 | -32,768 to 32,767 |
| int32 or rune | -2,147,483,648 to 2,147,483,647 |
| int64 | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
| uintptr | Unsigned integer large enough to store the uninterpreted bits of a pointer value |
| uint | Either 32 or 64 bits (platform-dependent) |
| int | Either 32 or 64 bits (platform-dependent) |
| float32 | 32-bit floating-point numbers |
| float64 | 64-bit floating-point numbers |
| complex64 | Complex numbers with float32 real and imaginary parts |
| complex128 | Complex numbers with float64 real and imaginary parts |