Types
There are 3 basic data types in Go languages which are:
- Numbers: numbers are divided into three sub-categories that are:
- Integers: In Golang, there are 4(four) different sizes for both signed and unsigned integers
Data Type | Description |
---|---|
int8 | 8-bit signed integer, range -128 to 127 |
int16 | 16-bit signed integer, range -(2^15) to (2^15)-1 |
int32 | 32-bit signed integer, range -(2^31) to (2^31)-1 |
int64 | 64-bit signed integer, range -(2^63) to (2^63)-1 |
uint8 | 8-bit unsigned integer, range 0 to 255 |
uint16 | 16-bit unsigned integer, range 0 to (2^16)-1 |
uint32 | 32-bit unsigned integer, range 0 to (2^32)-1 |
uint64 | 64-bit unsigned integer, range 0 to (2^64)-1 |
int | Both int and uint contain same size, either 32 or 64 bit. |
uint | Both int and uint contain same size, either 32 or 64 bit. |
byte | It is a synonym of uint8. |
- Float Numbers
Data Type | Description |
---|---|
float32 | 32-bit IEEE 754 floating-point number |
float64 | 64-bit IEEE 754 floating-point number |
- Complex Numbers
Data Type | Description |
---|---|
complex64 | Complex numbers which contain float32 as a real and imaginary component. |
complex128 | Complex numbers which contain float64 as a real and imaginary component. |
Booleans
Strings