Go Data Types
Go Language- Data Types
Data types are the keywords that describe the space occupied by a variable and how it is interpreted. They are used to declare variable and functions. Like in every programming language, Golang has a set of data types. There are 4 general classifications:
Boolean types :
These types can either be true or false.
Numeric types :
These types are arithmetic. They are further classifies into Integer types and Floating points.
It holds whole numbers. It can hold negative values if it is signed and it starts from zero if its unsigned. The range of values change according to the bits.
- uint8 − Unsigned 8-bit integers (0 to 255)
- uint16 − Unsigned 16-bit integers (0 to 65535)
- uint32 − Unsigned 32-bit integers (0 to 4294967295)
- uint64 − Unsigned 64-bit integers (0 to 18446744073709551615)
- int8 − Signed 8-bit integers (-128 to 127)
- int16 − Signed 16-bit integers (-32768 to 32767)
- int32 − Signed 32-bit integers (-2147483648 to 2147483647)
- int64 − Signed 64-bit integers (-9223372036854775808 to 9223372036854775807)
It hold fractional and imaginary values. It holds a range of values based on the bits.
- float32 − IEEE-754 32-bit floating-point numbers
- float64 − IEEE-754 64-bit floating-point numbers
- complex64 − Complex numbers with float32 real and imaginary parts
- complex128 − Complex numbers with float64 real and imaginary parts
Some of the generally used types.
- uintptr − an unsigned integer to store the uninterrupted bits of a pointer value
String types :
This type holds a set of characters and they are usually enclosed in a double quotes. String is immutable which means they can’t be modified after initialization. It also has a set of functions for modification. After any modification, a new memory location is allocated to the new value.
Derived types :
This type includes